日期:2014-05-20  浏览次数:20962 次

WPF下 ComboBox控件的SelectedValue属性双向绑定对象 的问题
我的ComboBox控件 在SeletedValue上双向绑定了一个属性MySelectedValue,现在的问题是我改变了ComboBox的选中项之后,MySelectedValue的值能随着改变,但是如果我再后台改变了MySelectedValue的值界面上ComboBox控件的选中项却没有任何修改,卡在这好几天了,高手请帮忙。
我的代码
[code=XAML]
<ComboBox x:Name="cmbGroupList"  Style="{DynamicResource ComboBoxStyle1}" ItemsSource="{Binding OutputGroupList}" SelectedValue ="{Binding MySelectedGroup, Mode=TwoWay}">                                    <i:Interaction.Triggers>
             <i:EventTrigger EventName="SelectionChanged">
                        <ei:CallMethodAction MethodName="UpdateOutputListBox" TargetObject="{Binding}"/>
             </i:EventTrigger>
                </i:Interaction.Triggers>
            </ComboBox>

[/code]

private string m_selectedGroup;
        public string SelectedGroup
        {
            get
            {
                return this.m_selectedGroup;
            }
            set
            {
                this.m_selectedGroup = value;
                this.NotifyPropertyChanged("SelectedGroup");
            }
        }

------解决方案--------------------
SelectedValue ="{Binding MySelectedGroup, Mode=TwoWay}">   

但你后台明明是 public string SelectedGroup 啊。
------解决方案--------------------

SelectedValue ="{Binding Path=SelectedGroup, Mode=TwoWay}">