Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Add x:Key to Datagrid, ListView style #980

Closed
Yopler opened this issue Sep 2, 2021 · 7 comments
Closed

[Feature request] Add x:Key to Datagrid, ListView style #980

Yopler opened this issue Sep 2, 2021 · 7 comments
Projects

Comments

@Yopler
Copy link

Yopler commented Sep 2, 2021

Is your feature request related to a problem? Please describe.
I really like the default style of the Datagrid but I can't make my own default Datagrid Style base on the Handy Control one. I have see that the same problem is present for the ListView style, and maybe some others.

Describe the solution you'd like
It's possible to add a x:Key = DataGridBaseStyle (using the default naming of the other BaseStyle) to the DataGrid Style and then make it default <Style TargetType="DataGrid" BaseOn="{StaticRessource DataGridBaseStyle}"/>

Describe alternatives you've considered
A first alternative is to make all the changes on the <DataGrid/> Tag.
But Currently I have litterally copy/paste the default style and made the Changes I wanted.

PS : Sorry for this approximative English ! ^^

@ghost1372
Copy link
Member

you can use like this

<Style TargetType="DataGrid" BasedOn="{StaticResource {x:Type DataGrid}}"/>

@Yopler
Copy link
Author

Yopler commented Sep 3, 2021

Doesn't seem to work for me.

Here an example of the kind of changes I want to make :

<Style x:Key="CustomDataGridRowStyle" TargetType="DataGridRow" BasedOn="{StaticResource DataGridRowStyle}">
        <Setter Property="Background" Value="{StaticResource LayerBackground}"/>
</Style>

<Style TargetType="DataGrid" BasedOn="{StaticResource {x:Type DataGrid}}">
        <Setter Property="AutoGenerateColumns" Value="False"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="RowStyle" Value="{StaticResource CustomDataGridRowStyle}"/>
</Style>

And I get the following result :
image

I feel like it takes the default style of WPF and not the one of HandyControl.

@Yopler
Copy link
Author

Yopler commented Sep 3, 2021

Same problem !

But I just found a solution !
In the previous comment, the style Tag was on the App.xaml file.
The <Style TargetType="DataGrid" BasedOn="{StaticResource {x:Type DataGrid}}"/> solution works if it is in another file ressources. I suggest in the MainWindow.xaml file to make it use in the all application.

However, I think it can be an improvement to create an x:Key = DataGridBaseStyle ^^

@ghost1372
Copy link
Member

@NaBian do you have any idea? can we make x:Key = DataGridBaseStyle?

@NaBian
Copy link
Member

NaBian commented Oct 12, 2021

if you want to custom datagrid style, you can refer to datagrid.small style, it's easy.

@ghost1372 ghost1372 added this to Todo in Roadmap Oct 12, 2021
@Yopler
Copy link
Author

Yopler commented Oct 13, 2021

Close x:key="Datagrid.Small" with commits

@Yopler Yopler closed this as completed Oct 13, 2021
Roadmap automation moved this from Todo to Done Oct 13, 2021
@Yopler
Copy link
Author

Yopler commented Oct 13, 2021

My bad, ListView doesn't have a x:Key yet 😅😅

@Yopler Yopler reopened this Oct 13, 2021
@NaBian NaBian closed this as completed in 9efb6a0 Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Roadmap
  
Done
Development

No branches or pull requests

3 participants