0

当设置为 false 时,我必须更改Text组合框的属性,并且当同一控件为 trueIsEnabled时,它​​可以从项目源中手动选择字段,这可能吗?IsEnabled

XAML:

<ComboBox Name="cmbIntervals"
                        Grid.Row="5"
                        Grid.Column="1"
                        Width="150"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"
                        IsEnabled="{Binding ElementName=chkBox,
                                              Path=IsChecked}"
                        ItemsSource="{Binding Source={x:Static res:Parameters.Instance},
                                                Path=Intervals}"
                        Text="{Binding [Intervals],                                         Mode=TwoWay,
                                         UpdateSourceTrigger=PropertyChanged}" >
              <ComboBox.Style>
                    <Style TargetType="{x:Type ComboBox}">                       
                        <Style.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Text" Value="1"/>                            
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </ComboBox.Style>
              </ComboBox>
4

1 回答 1

0

只需签入 ViewModel

if(!IsChecked)
{
TextProperty="1"; //Propery to bind to ComboBox Text
}
于 2013-07-23T12:53:31.837 回答