If I make a UserControl, it has numbers properties. How I can use them? My UserControl contained several Shapes and I need to bind a Foreground property to all Shape.Fill. But I do not know how to do it.
A:
If you set your properties to Public, you will be able to access your UserControl's properties from outside its own class.
I'm not sure if this is your issue though. Please elaborate on your issue.
Jon
2009-04-06 17:05:32
A:
- Use element name binding inside your user control with an existing brush dependency property
<UserControl x:Name="myUC" ...> <Rectangle Fill="{Binding ElementName=myUC, Path=Background}" /> <Rectangle Fill="{Binding ElementName=myUC, Path=Background}" /> <Rectangle Fill="{Binding ElementName=myUC, Path=Background}" /> </UserControl>
- Use element name binding inside your user control with a new brush dependency property.
<UserControl x:Name="myUC" ...> <Rectangle Fill="{Binding ElementName=myUC,Path=ShapeBackground}" /> <Rectangle Fill="{Binding ElementName=myUC, Path=ShapeBackground}" /> <Rectangle Fill="{Binding ElementName=myUC, Path=ShapeBackground}" /> </UserControl>
markti
2009-06-01 01:16:56