C# DependencyProperty绑定仅触发一次

C# DependencyProperty绑定仅触发一次,c#,wpf,binding,dependency-properties,C#,Wpf,Binding,Dependency Properties,我有一个绑定到usercontrol上的依赖项属性的多绑定转换器。转换器似乎在初始化时触发一次,但在其多绑定项引发更改通知时不会再次触发 我不确定,但我怀疑问题可能是绑定被覆盖了 我会发布所有我认为相关的代码。如果我遗漏了什么,请告诉我 XAML绑定到依赖项属性**已编辑**: <views:TextBlockComboBox.SelectedIndex> <MultiBinding Converter="{StaticResource UIDToInd

我有一个绑定到usercontrol上的依赖项属性的多绑定转换器。转换器似乎在初始化时触发一次,但在其多绑定项引发更改通知时不会再次触发

我不确定,但我怀疑问题可能是绑定被覆盖了

我会发布所有我认为相关的代码。如果我遗漏了什么,请告诉我

XAML绑定到依赖项属性**已编辑**:

<views:TextBlockComboBox.SelectedIndex>
            <MultiBinding Converter="{StaticResource UIDToIndexConverter}">
                <Binding Path="DataLayer.SupplierUID"></Binding>
                <Binding Path="CoreSuppliers"></Binding>
                <Binding Path="DataLayer" />
            </MultiBinding>
        </views:TextBlockComboBox.SelectedIndex>
编辑工作绑定

<views:TextBlockComboBox.Visibility>
                <MultiBinding Converter="{StaticResource LayerEditConverter}">
                    <Binding Path="DataLayer" />
                    <Binding>
                        <Binding.Source>
                            <system:String>Core</system:String>
                        </Binding.Source>
                    </Binding>

                </MultiBinding>
            </views:TextBlockComboBox.Visibility>

核心
EDIT我发现,如果我删除usercontrol与selectedindex依赖属性的绑定,转换器就会启动

<ComboBox 
            x:Name="ThisComboBox"
            ItemsSource="{Binding Items, ElementName=ThisUserControl, Mode=TwoWay}" 
            SelectedItem="{Binding SelectedItem, ElementName=ThisUserControl, Mode=TwoWay}"
            SelectedIndex="{Binding SelectedIndex, ElementName=ThisUserControl, Mode=TwoWay}" --WITHOUT THIS IN CONVERTER FIRES__
            SelectionChanged="selectedItemChanged"
            VerticalAlignment="Center"
            DisplayMemberPath="{Binding DisplayPath, ElementName=ThisUserControl, Mode=TwoWay}" 
         />


您确定您的多绑定项目会发出更改通知吗
CoreSuppliers
看起来像一个集合,更改集合不一定会引起
PropertyChanged
。可能不是问题的根源,但您应该在SelectedIndex setter中使用
SetValue
而不是
SetCurrentValue
。@Bahman\u很好,从转换器代码中,我们可以得出结论,这是一个
可观察的集合
。当引发CollectionChanged事件时,它不会触发绑定。首先感谢您的响应。看来我错过了多重绑定的一个绑定条件,我在四处玩,试图让它工作。我在其他多重绑定条件中发现你说的是真的。为了解决这个问题,我添加了一个绑定来包含DataLayer属性,该属性调用RaisePropertyChanged。这是否会导致转换器再次启动,而不管其他2个绑定元素是否发出propertychanged通知?在多重绑定中,每当任何绑定属性发生更改,源属性都会相应地更新,从而调用convert方法。因此,如果它仍然不起作用,那么一定是其他原因导致了问题。你试过克莱门斯的建议吗?
<views:TextBlockComboBox.Visibility>
                <MultiBinding Converter="{StaticResource LayerEditConverter}">
                    <Binding Path="DataLayer" />
                    <Binding>
                        <Binding.Source>
                            <system:String>Core</system:String>
                        </Binding.Source>
                    </Binding>

                </MultiBinding>
            </views:TextBlockComboBox.Visibility>
<ComboBox 
            x:Name="ThisComboBox"
            ItemsSource="{Binding Items, ElementName=ThisUserControl, Mode=TwoWay}" 
            SelectedItem="{Binding SelectedItem, ElementName=ThisUserControl, Mode=TwoWay}"
            SelectedIndex="{Binding SelectedIndex, ElementName=ThisUserControl, Mode=TwoWay}" --WITHOUT THIS IN CONVERTER FIRES__
            SelectionChanged="selectedItemChanged"
            VerticalAlignment="Center"
            DisplayMemberPath="{Binding DisplayPath, ElementName=ThisUserControl, Mode=TwoWay}" 
         />