Click here to Skip to main content
15,568,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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"/>
    <DataTrigger Binding="{Binding ShowDataRow}" Value="False">
        <Setter Property="Visibility" Value="Collapsed"/>
    <DataTrigger Binding="{Binding ShowDataRow}" Value="True">
        <Setter Property="Visibility" Value="Visible"/>

    <DataTrigger Binding="{Binding IsDeviceConnected}" Value="True">
        <Setter Property="IsEnabled" Value="False"/>
    <DataTrigger Binding="{Binding IsDeviceConnected}" Value="False">
        <Setter Property="IsEnabled" Value="True"/>

<datagrid style="{StaticResource DataGridEnableStyle}">
Updated 7-Nov-16 4:40am

1 solution

Set TargetType="DataGrid" on both styles.
Share this answer
partha143 7-Nov-16 9:17am    
John, I have done that. I'm sorry I missed out while posting the question.
#realJSOP 7-Nov-16 9:18am    
Edit your question to show the entire style for both the base and the derived style.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900