WPF组合框更新源触发器

时间:2013-07-31 08:38:45

标签: wpf combobox updatesourcetrigger

我添加了组合框的触发器,即

  • 当组合框为“已禁用”时,“文本”属性应设置为“1” 并将updatesourcetrigger添加到属性已更改。

  • 当组合框为“启用”时,应选择“文本”属性并添加 更新源触发器以更改属性。

但问题是,当组合框处于禁用状态且“文本”属性设置为“1”时,我无法调用更新源触发器。

以下是XAML代码段:

<ComboBox Name="cmbIntervals"
                        Grid.Row="5"
                        Grid.Column="1"
                        Width="150"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"
                        IsEnabled="{Binding ElementName=chkRollingInterval,
                                              Path=IsChecked}"
                        ItemsSource="{Binding Source={x:Static es:MasterParameters.Instance},
                                                Path=NoOfIntervals}" 
                        Tag="{Binding Path=[NoOfIntervals], Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                        >
                  <ComboBox.Style>
                    <Style TargetType="{x:Type ComboBox}">
                      <Style.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                        <Setter Property="Text" Value="1"/>
                        <Setter Property="Text" Value="{Binding RelativeSource={RelativeSource Self}, Path=Tag, Mode=TwoWay, UpdateSourceTrigger=Default}"/>
                      </Trigger>
                      <Trigger Property="IsEnabled" Value="True">
                        <Setter Property="Text" Value="{Binding RelativeSource={RelativeSource Self}, Path=Tag, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                      </Trigger>
                      </Style.Triggers>
                   </Style>
                </ComboBox.Style>
              </ComboBox>

从上面的XAML代码到我为组合框“Disabeld”模式更新“Text”属性为“1”时,我需要将此“1”值更新为源属性,即“Tag”,并从那里更新为“NoOfIntervals”但它没有发生。

谢谢, 纳格

0 个答案:

没有答案
相关问题