ListBoxItem.ItemContainerStyle resets MaterialDesign style even with BasedOn property set
See original GitHub issueSetting ListBox item style in the following way
<ListBox.ItemContainerStyle>
<Style BasedOn="{StaticResource {x:Type ListBoxItem}}" TargetType="{x:Type ListBoxItem}">
...
</Style>
</ListBox.ItemContainerStyle>
…resets the actual ListBoxItem style to default (not material design).
However, the same exact approach works fine for TreeView and TreeViewItem.
I fixed it by setting BasedOn property to “{StaticResource MaterialDesignListBoxItem}”, but it’s suboptimal because it relies on a key that may or may not change.
Perhaps I’m doing something wrong?
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Issues with ListBoxItem selection when ItemContainerStyle ...
1 Answer 1. Sorted by: Reset to default. Highest score (default) ...
Read more >ItemsControl.ItemContainerStyle Property
Gets or sets the Style that is applied to the container element generated ... is to set the ItemContainerStyle property of the ListBox...
Read more >c# - WPF MVVM ColorLister with navigation
This tab will then be represented by its Icon property from inheriting from IPageViewModel . ColorList_Tab supports adding, editing, deleting ...
Read more >WPF TabControl: Styling the TabItems
Learn how to style the TabItem elements of the WPF TabControl with this complete ... the background color of the tabs based on...
Read more >Release notes
In Style, a new method, called RevertToDefault(), now sets the style of the cell, row or column back to its default value. In...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
TargetType=“{x:Type MaterialDesignListBoxItem}” should be “{x:Type ListBoxItem}” I think. The original error is probably of the same cause as http://stackoverflow.com/a/7780980
Did you change the style to
?
Because that worked for me.