3

すべて正常に動作するデータ テンプレート内のさまざまなボタンの複数値コンバーターに同じ値を渡すシナリオがあります。しかし、同じコンテンツを

<telerik:RadButton.Visibility>
    <MultiBinding Converter="{StaticResource multiValueToBooleanConverter}" ConverterParameter="ViewCommentsDialog">
        <Binding Path="DataContext.CanEdit" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}" />
        <Binding Path="DataContext.CanView" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}" />
        <Binding Path="Comment"/>
        <Binding Path="ExecutionId"/>
    </MultiBinding>
</telerik:RadButton.Visibility>

コード:

<DataTemplate>
    <StackPanel Orientation="Horizontal">
        <telerik:RadButton Margin="2" Command="{Binding DataContext.ViewCommentCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" CommandParameter="{Binding}">
            <telerik:RadButton.Visibility>
                <MultiBinding Converter="{StaticResource multiValueToBooleanConverter}" ConverterParameter="ViewCommentsDialog">
                    <Binding Path="DataContext.CanEdit" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}" />
                    <Binding Path="DataContext.CanView" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}" />
                    <Binding Path="Comment"/>
                    <Binding Path="ExecutionId"/>
                </MultiBinding>
            </telerik:RadButton.Visibility>
            <telerik:RadButton.Content>
                <Image Width="20" Height="20" Source="pack://application:,,,/Mizuho.Minar.UI.Common;component/png/Comments.png" />
            </telerik:RadButton.Content>
        </telerik:RadButton>
        <telerik:RadButton Margin="2" Command="{Binding  DataContext.AddCommentCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" CommandParameter="{Binding}">
            <telerik:RadButton.Visibility>
                <MultiBinding Converter="{StaticResource multiValueToBooleanConverter}" ConverterParameter="AddCommentDialog">
                    <Binding Path="DataContext.CanEdit" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}" />
                    <Binding Path="DataContext.CanView" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}" />
                    <Binding Path="Comment"/>
                    <Binding Path="ExecutionId"/>
                </MultiBinding>
            </telerik:RadButton.Visibility>
            <telerik:RadButton.Content>
                <Image Width="20" Height="20" Source="pack://application:,,,/Mizuho.Minar.UI.Common;component/png/Comment-Add.png" />
            </telerik:RadButton.Content>
        </telerik:RadButton>
        <telerik:RadButton Margin="2" Command="{Binding DataContext.ViewBreaksCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" CommandParameter="{Binding}">
            <telerik:RadButton.Visibility>
                <MultiBinding Converter="{StaticResource multiValueToBooleanConverter}" ConverterParameter="ViewBreaksDialog">
                    <Binding Path="DataContext.CanEdit" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}" />
                    <Binding Path="DataContext.CanView" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}" />
                    <Binding Path="Comment"/>
                    <Binding Path="ExecutionId"/>
                </MultiBinding>
            </telerik:RadButton.Visibility>
            <telerik:RadButton.Content>
                <Image Width="20" Height="20" Source="pack://application:,,,/Mizuho.Minar.UI.Common;component/png/Folder-Bug.png" />
            </telerik:RadButton.Content>
        </telerik:RadButton>
    </StackPanel>
</DataTemplate>
4

1 に答える 1