WPF Bind User Control Coordinates
I have a User Control added to a Canvas. In another area o开发者_如何学JAVAf the application I have two TextBoxes that will get 2 values : X and Y. I need a two-way binding between the user control's top left corner coordinates and those 2 textboxes. I don't mind implementing a Converter or doing some calculations, but I need a push in the right direction.
<UserControl Canvas.Left="{Binding Text, ElementName=myFirstTextBox, Mode=TwoWays}"
Canvas.Top="{Binding Text, ElementName=mySecondTextBox, Mode=TwoWays}" ... />
But I can only strongly recommend you to use some sort of custom ValidationRule
on your TextBoxes, in order to disallow any input that does not represent a valid number, otherwise you will get a nice crash.
精彩评论