开发者

WPF Bind User Control Coordinates

开发者 https://www.devze.com 2022-12-24 19:48 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消