0

が 0 より大きい場合 (基本的に、オプションが選択されてComboBoxいる場合)にトリガーを設定するにはどうすればよいですか? 私が持っているのは 2 つのes ですが、ユーザーはそのうちの 1 つしか選択できません。したがって、A から最初のオプションを選択すると、B は0 を取得する必要があり、その逆も同様です。SelectedIndexComboBoxComboBoxComboBoxComboBoxSelectedIndex

以下をいじってみましたが、必要なロジックをキャプチャする方法がわかりません。

<ComboBox ItemsSource="{Binding AvailableStatuses}"
          SelectedItem="{Binding SelectedStatus}"
          Grid.Row="1" Grid.Column="1" DisplayMemberPath="Name" 
          x:Name="Statuses">
    <ComboBox.Style>
        <Style TargetType="{x:Type ComboBox}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding ElementName=Decisions}" Value="0">
                    <Setter Property="SelectedIndex" Value="0" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </ComboBox.Style>
</ComboBox>

どのような種類のトリガーを確認する必要がありますか?

4

3 に答える 3

3

「SelectedStatus」プロパティがどこにあっても、ViewModel にこのロジックを含める方がはるかに簡単だと思います。入ってくる値が 0 より大きい場合は、他のプロパティ ("SelectedStatus2"?) を 0 に設定し、その逆も同様です。

于 2011-06-08T22:16:19.710 に答える
1

SelectedIndex が 0 より大きい場合に True/False を返すコンバーターを作成できます。

<DataTrigger Binding="{Binding ElementName=Decisions, 
    Converter={StaticResource IsValueGreaterThanZeroConverter}}" Value="True">
于 2011-06-08T15:14:49.583 に答える
1

B のプロパティをA のSelectedIndexプロパティにバインドしないのはなぜですか?ComboBoxSelectedIndexComboBox

于 2011-06-08T14:46:43.410 に答える