在 .cs .net silverlight 代码中绑定 SelectedIndexProperty 的 XAML 等效项是什么?
我一直在 silverlight 中使用绑定,并且已经弄清楚如何在代码中绑定,但更愿意将绑定保留在 XAML 中。
这是在我的 .cs 文件中运行的代码:
System.Windows.Data.Binding IDBinding = new System.Windows.Data.Binding("ID");
IDBinding.Source = MyTrans;
IDBinding.Mode = System.Windows.Data.BindingMode.TwoWay;
cbComboBox.SetBinding(ComboBox.SelectedIndexProperty, IDBinding);
这是我的 XAML 行:
<ComboBox x:Name="cbComboBox" Margin="4,20,6,0" Foreground="#FFD41D1D" Height="25" VerticalAlignment="Top">
如何在 XAML 中表达相同的内容?
谢谢!
-射线
I have been playing with bindings in silverlight, and have figured out how to bind in code, but would prefer to keep the binding in the XAML.
This is the code that works in my .cs file:
System.Windows.Data.Binding IDBinding = new System.Windows.Data.Binding("ID");
IDBinding.Source = MyTrans;
IDBinding.Mode = System.Windows.Data.BindingMode.TwoWay;
cbComboBox.SetBinding(ComboBox.SelectedIndexProperty, IDBinding);
this is my XAML line:
<ComboBox x:Name="cbComboBox" Margin="4,20,6,0" Foreground="#FFD41D1D" Height="25" VerticalAlignment="Top">
How do I express the same thing in XAML?
Thanks!
-Ray
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您将 ComboBox 的父控件(或组合框本身)的 DataContext 设置为 MyTrans,则应执行以下操作:
Assuming that you set the DataContext of the parent control of the ComboBox (or on the combobox itself) to MyTrans, the following should do it: