C# 没有任何绑定集的属性上的绑定错误

C# 没有任何绑定集的属性上的绑定错误,c#,xaml,C#,Xaml,Visual Studio在其输出中显示以下错误: System.Windows.Data Error: 40 : BindingExpression path error: 'Text' property not found on 'object' ''PropertyAppraisalWorkflowViewModel' (HashCode=35281714)'. BindingExpression:Path=Text; DataItem='PropertyAppraisal

Visual Studio在其输出中显示以下错误:

System.Windows.Data Error: 40 :
    BindingExpression path error:
    'Text' property not found on 'object' ''PropertyAppraisalWorkflowViewModel' (HashCode=35281714)'. BindingExpression:Path=Text;
DataItem='PropertyAppraisalWorkflowViewModel' (HashCode=35281714);
target element is 'ComboBox' (Name='cmbWorkflowView');
target property is 'Text' (type 'String')
奇怪的是,我没有为cmbWorkflowView控件绑定(甚至没有使用)属性“Text”

下面是XAML的一个截断片段,错误是说它有问题:

    <Grid Name="grdWorkflow">
        <Grid.Resources>
            <Style TargetType="ComboBox" BasedOn="{StaticResource DefaultComboBox}" />
        </Grid.Resources>

        <ComboBox DockPanel.Dock="Right"
                  Name="cmbWorkflowView"
                  ItemsSource="{Binding ViewOptions}"
                  SelectedItem="{Binding SelectedView}"
                  props:ComboBoxProperties.SelectionChangedCommand="{Binding SelectWorkflowView}" />
    </Grid>


如您所见,讨论中的组合框甚至没有使用文本字段,更不用说绑定它了。是什么导致了错误?(见下文。我解决了这个问题,但由于我在其他任何地方都找不到与此问题相同的解决方案,因此我决定将该解决方案发布在此处,以防它能帮助其他人解决问题。)

解决方案的关键是风格。在代码中,样式由更多XAML分隔。我忘记了组合框有一个与之相关的样式。当我按照样式查找其来源时,我发现了以下内容。(为了可读性,此选项被截断,实际样式更复杂。)


该样式已绑定“Text”属性。一旦我删除了“Text”属性的Setter,错误就消失了

    <Style x:Key="DefaultComboBox" TargetType="ComboBox">
        <Setter Property="Height" Value="{StaticResource DefaultControlHeight}" />
        <Setter Property="Background" Value="{StaticResource ComboBoxEditableFieldBrush}" />
    </Style>

    <Style x:Key="DefaultComboBox" TargetType="ComboBox">
        <Setter Property="Height" Value="{StaticResource DefaultControlHeight}" />
        <Setter Property="Background" Value="{StaticResource ComboBoxEditableFieldBrush}" />
    </Style>