本文介绍了只能基于具有基本类型“datagrid”的目标类型的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为Datagrid编写2个样式(一个用于DataGrid启用,另一个用于DataGridRow),这违反了使用BasedOn之外的行为。但是当我使用BasedOn时,我得到:

I want to write 2 styles for Datagrid(one for DataGrid Enabling and another for DataGridRow) which is against the behavior apart from using BasedOn. But when I do use BasedOn I get :

Can only base on a Style with target type that is base type 'DataGrid'





如何实现这一目标?谢谢。



我尝试过:





How can I achieve this? Thank You.

What I have tried:

<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
    <DataTrigger Binding="{Binding ShowDataRow}" Value="False">
        <Setter Property="Visibility" Value="Collapsed"/>
    </datatrigger>
    <DataTrigger Binding="{Binding ShowDataRow}" Value="True">
        <Setter Property="Visibility" Value="Visible"/>
    </datatrigger>
</style.Triggers>



<Style.Triggers>
    <DataTrigger Binding="{Binding IsDeviceConnected}" Value="True">
        <Setter Property="IsEnabled" Value="False"/>
    </datatrigger>
    <DataTrigger Binding="{Binding IsDeviceConnected}" Value="False">
        <Setter Property="IsEnabled" Value="True"/>
    </datatrigger>
</style.Triggers>







<datagrid style="{StaticResource DataGridEnableStyle}">

推荐答案


这篇关于只能基于具有基本类型“datagrid”的目标类型的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 04:45