设置为modeTwoWay时,在UserControl的组合框中绑定到SelectedIndex的操作中断 [英] Binding to SelectedIndex in a Combobox in a UserControl breaks when setting to modeTwoWay

查看:53
本文介绍了设置为modeTwoWay时,在UserControl的组合框中绑定到SelectedIndex的操作中断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,它还为某些(相同的)userControl绑定,而对于某些用户控件,它最初并没有绑定.

It also, for some reason, binds for some of the (identical) userControls and for some it does not bind in the first place.

那些绑定的对象,绑定可以从代码开始工作,但是从UI设置时会中断.请帮忙.

Those that bind, the binding works from code but breaks when set from the UI.  Please help.

< Grid.Column ="1" 边距 =" 10,0,0,0" Grid.Row ="1" Horizo​​ntalAlignment =左" VerticalAlignment =" Center" MinWidth ="50" x : 名称 SelectedIndex =&; { ElementName = TreatmentButton, 路径

<ComboBox Grid.Column="1" Margin="10,0,0,0" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Center" MinWidth="50" x:Name="LeftComboBox" SelectedIndex="{Binding ElementName=TreatmentButton, Path

= LeftTSelection}"// 

=LeftTSelection}"/> 

C#相关代码:  UserControl

public IEnumerable LeftCBValues { set {LeftComboBox.ItemsSource = ; }}

public IEnumerable LeftCBValues { set { LeftComboBox.ItemsSource = value; } }

public 静态 DependencyProperty LeftTSelectionProperty = DependencyProperty .Register( "LeftTSelection" typeof ( typeof (

public static DependencyProperty LeftTSelectionProperty = DependencyProperty.Register("LeftTSelection", typeof(int), typeof(TreatmentButton));

public int LeftTSelection { 获取 { 返回 ( int )GetValue(LeftTSelectionProperty); } set {SetValue(LeftTSelectionProperty, ); }}

public int LeftTSelection { get { return (int)GetValue(LeftTSelectionProperty); } set { SetValue(LeftTSelectionProperty,value); } }

推荐答案

嗨Ayal,

您能提供无法使用的示例吗?

can u please provide the sample in which it isn't working.

看代码,似乎一切都很完美.描述您的问题的样本将更有助于解决您的问题.

Looking at the code it seems everything is perfect. A sample describing ur problem will be more helpful to resolve ur issue.


这篇关于设置为modeTwoWay时,在UserControl的组合框中绑定到SelectedIndex的操作中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆