将附加属性绑定到DataTrigger

时间:2011-12-22 16:14:34

标签: wpf datatrigger commandbinding

单击时,datatrigger不会引发MouseLeftButtonDown事件。它目前也被图像控件使用并且工作正常。我不知道为什么不举起这个活动?我用MouseEnter进行了测试,效果很好。

    <Style TargetType="ListViewItem" BasedOn="{StaticResource ContentListViewItemStyle}" x:Key="MainContentListViewItemStyle">
    <Setter Property="Height" Value="68" />
    <Setter Property="Background" Value="Blue"/>
    <Setter Property="Width" Value="Auto" />
    <Setter Property="HorizontalAlignment" Value="Left" />
    <Setter Property="IsSelected" Value="{Binding Path=IsSelected}" />
    <Setter Property="Acb:CommandBehavior.Event" Value="MouseLeftButtonDown" />
    <Setter Property="Acb:CommandBehavior.Command" Value="{x:Static Common:CommandExtension.ClickOnContentButton}" />
    <Setter Property="Acb:CommandBehavior.CommandParameter" Value="{Binding Path=.}" />

    <Style.Resources>
        <Common:SelectedShowConverter x:Key="ShowConverter" />
    </Style.Resources>
    <Style.Triggers>
        <DataTrigger Binding="{Binding Path=Show}" Value="ExpendedFolder">
            <Setter Property="Background" Value="{StaticResource ListViewExpendedFolderImg}" />
            <Setter Property="Background" Value="Red" />
            <Setter Property="Width" Value="{Binding Path=ActualWidth, RelativeSource=
                {RelativeSource Mode=FindAncestor,AncestorType={x:Type ItemsPresenter}}}" />
        </DataTrigger>
        <DataTrigger Binding="{Binding Path=Show}" Value="ExpendedSingle">
            <Setter Property="Background" Value="Yellow" />
            <Setter Property="Background" Value="{StaticResource ListViewExpendedSingleImg}" />
            <Setter Property="Width" Value="{Binding Path=ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ItemsPresenter}}}" />
        </DataTrigger>

        <DataTrigger Binding="{Binding Path=IsVisible}" Value="False">
            <Setter Property="Visibility" Value="Collapsed" />
        </DataTrigger>
    </Style.Triggers>
</Style>

如果有帮助,我看到mouseleftbuttondown事件从不调用commandexecutionstrategy类的execute方法。可能是它被处理了吗?

0 个答案:

没有答案