0

要素を選択的に表示/非表示にするために使用するこのバインディングがあります。

<Binding XPath="InputFileIsNeeded">
    <Binding.Converter>
        <tl:IsEnabledToStringConverter 
            DisabledValue="Collapsed"
            EnabledValue="Visible" />
    </Binding.Converter>
</Binding>

上記のバインディングと、コマンド ライン引数 'Setup' へのバインディングに基づいて、選択的に表示/非表示にする必要がある要素があります。

<DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.StartArg}" Value="Setup">
    <Setter Property="Visibility" Value="Visible" />
</DataTrigger>

これらのバインディングの両方を以下に適用する必要があるため、次の要素は「セットアップ」モードで「InputFileIsNeeded」が true の場合にのみ表示されます。

    <Style x:Key="ColumnCountSpinner" TargetType="{x:Type ScrollBar}">
        <Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
        <Setter Property="Width" Value="Auto"/>
        <Setter Property="MinHeight" Value="25"/>
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>                

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollBar}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Label Content="Column Count:" 
                                   Grid.Column="0" />

                        <Border BorderThickness="1" BorderBrush="Gray" Grid.Column="1">
                            <Grid Margin="2">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <TextBlock VerticalAlignment="Center" FontSize="12" MinWidth="25" Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}}" Grid.Column="0" />
                                <Grid Grid.Column="1" x:Name="GridRoot" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Background="{TemplateBinding Background}">
                                    <Grid.RowDefinitions>
                                        <RowDefinition MaxHeight="18"/>
                                        <RowDefinition Height="0.00001*"/>
                                        <RowDefinition MaxHeight="18"/>
                                    </Grid.RowDefinitions>
                                    <RepeatButton x:Name="DecreaseRepeat" Command="ScrollBar.LineDownCommand" Focusable="False">
                                        <Grid>
                                            <Path x:Name="DecreaseArrow" Stroke="{TemplateBinding Foreground}" StrokeThickness="1" Data="M 0 4 L 8 4 L 4 0 Z"/>
                                        </Grid>
                                    </RepeatButton>
                                    <RepeatButton Grid.Row="2" x:Name="IncreaseRepeat" Command="ScrollBar.LineUpCommand" Focusable="False">
                                        <Grid>
                                            <Path x:Name="IncreaseArrow" Stroke="{TemplateBinding Foreground}" StrokeThickness="1" Data="M 0 0 L 4 4 L 8 0 Z"/>
                                        </Grid>
                                    </RepeatButton>
                                </Grid>
                            </Grid>
                        </Border>
                    </Grid>

                </ControlTemplate>
            </Setter.Value>
        </Setter>

XPath を MultiDataTrigger にバインドする方法に問題があります。私はフォローしようとしましたが、2つのエラーが発生しました(1)「}」が必要です(「XPath =」上)および(2)特定の要素がないため、ここでは明らかに使用できません(これはCondition要素内にあると思います)。

MultiDataTrigger またはその他のメカニズムを使用してこれら 2 つのプロパティをバインドする方法を教えてもらえますか?

4

1 に答える 1

0

(次の情報は、編集で質問の作成者によって提供されました。)

特定のケースに合わせて変更できる例を見つけました。OP の Style に以下が追加されます。

<Style.Triggers>
    <MultiDataTrigger>
        <!-- Condition for 'Setup' and InputFileIsNeeded = true -->
        <MultiDataTrigger.Conditions>
            <Condition Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.StartArg}" Value="Setup" />
            <Condition Binding="{Binding XPath=InputFileIsNeeded}" Value="true" />
        </MultiDataTrigger.Conditions>
    </MultiDataTrigger>
<Style.Triggers>
于 2015-01-21T20:42:19.537 に答える