小编olv*_*rmr的帖子

ComboBox SelectedItem绑定未更新

我有点困惑:这有效:

<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
            <Label Content="Rol" />
            <ComboBox ItemTemplate="{StaticResource listRollen}"
                      Height="23" Width="150"
                      SelectedItem="{Binding Path=SelectedRol, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                      ItemsSource="{Binding Path=allRollen, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
        </StackPanel>
Run Code Online (Sandbox Code Playgroud)

和SelectedRol的属性是:

public TblRollen SelectedRol
    {
        get { return _selectedRol; }
        set
        {
            if (_selectedRol != value)
            {
                _selectedRol = value;
                OnPropertyChanged("SelectedRol");
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

但这不起作用:

<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
            <Label Content="Soort" />
            <ComboBox ItemTemplate="{StaticResource listSoorten}"
                      Height="23" Width="150"
                      ItemsSource="{Binding Path=allSoorten}"
                      SelectedItem="{Binding Path=SelectedProduct, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
        </StackPanel>
Run Code Online (Sandbox Code Playgroud)

具有以下属性SelectedProduct:

public TblProduktSoorten SelectedProduct
    {
        get { return _selectedPSoort; }
        set
        {
            if (_selectedPSoort != …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml binding combobox

1
推荐指数
4
解决办法
2万
查看次数

标签 统计

binding ×1

c# ×1

combobox ×1

wpf ×1

xaml ×1