Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在画布上添加了一个用户控件。在应用程序的另一个区域,我有两个文本框,它们将获得 2 个值:X 和 Y。我需要在用户控件的左上角坐标和这两个文本框之间进行双向绑定。我不介意实现转换器或进行一些计算,但我需要朝着正确的方向前进。
<UserControl Canvas.Left="{Binding Text, ElementName=myFirstTextBox, Mode=TwoWays}" Canvas.Top="{Binding Text, ElementName=mySecondTextBox, Mode=TwoWays}" ... />
但我只能强烈建议您在您的 TextBoxes 上使用某种自定义ValidationRule,以禁止任何不代表有效数字的输入,否则您将得到一个很好的崩溃。
ValidationRule