Error template disappears from Cell after changing menu in HamburgerMenu
See original GitHub issueDescribe the bug
Hello I have a WPF application where I use Prism and Mahapps. I have a DataGrid with model which implements INotifyDataErrorInfo Interface, after loading data to grid I see some cells with red border (the value is invalid there) but if go to another MenuItem in HamburgerMenu and then I back to the first MenuItem the red border are disappeared. I have tried using AdornerDecorator but it didn’t help. Then I have tried custom styles, and data temples for ErrorTemplate but it didn’t help too. But If I add following code, it works.
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MahApps.Styles.DataGridCell}" >
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
</MultiTrigger.Conditions>
</MultiTrigger>
</Style.Triggers>
</Style>
</DataGrid.Resources>
I have no idea why it behaves like that.
Steps to reproduce
- Make model which implements INotifyDataErrorInfo .
- Load some data to DataGrid, cells with incorrect data (validated by functions from INotifyDataErrorInfo ) should have red borders now.
- Change View via HamburgerMenu
- Back to View with Grid. Now red borders disappears.
- Add the code from description. Now it should work.
Here is the View with DataGrid
<UserControl x:Class="PrismJPKEditor.Modules.JPK.Views.Declaration"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True">
<DataGrid GridLinesVisibility="All" ItemsSource="{Binding SessionContext.JPKDataSource.Declaration.Declarations}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" >
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MahApps.Styles.DataGridCell}" >
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
</MultiTrigger.Conditions>
</MultiTrigger>
</Style.Triggers>
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn IsReadOnly="True" Width="auto" Header="Nazwa pola" Binding="{Binding FieldName}"/>
<DataGridTextColumn IsReadOnly="True" Width="auto" Header="Opis pola" Binding="{Binding Description}"/>
<DataGridTextColumn IsReadOnly="False" Width="auto" Header="Wartość pola" Binding="{Binding GridValue, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}"/>
</DataGrid.Columns>
</DataGrid>
</UserControl>
Expected behavior
The error template should stays after changing view via HamburgerMenu.
Actual behavior
The error template disappears.
Environment
MahApps.Metro version: v2.0.0
Windows build number: Win10 1909 [Version 10.0.18363.836]
Visual Studio: 2019 16.6.0
Target Framework: .Net Core 3.1 (v4.5.2, v4.7.2)
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
After clicking mobile menu and changing landscape ...
I have done a hamburger menu for a mobile phone and applied @media queries for different screen sizes and orientations. The problem:.
Read more >Mobile Menu Disappears When Touched - Support
Hi David, I checked your website on mobile and found the Hamburger menu is showing, but while clicked into the menu it suddenly...
Read more >Hamburger menu button missing on mobile device
I have tried switching to several other themes and it's exactly the same. The menu is selected as the primary menu. On the...
Read more >Mobile Navigation Hamburger Menu Going Blank
My site displays fine on desktop but frustratingly the hamburger dropdown menu flashes to white/blank when clicked on mobile.
Read more >Missing hamburger menu in mobile format
Hi. For some reason the menu has disappeared in mobile format It was working last time I checked? Currently building the site at ......
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
@GWawrzeniecki The default cell style is set to the
CellStyle
of theDataGrid
. So if you define a new global style in your App.xaml this style will not use (or only once). You can prevent this if you give your style a key and use this explicitly on your DataGrid.If you use this style always then you can set this to a global DataGrid style.
Hi @GWawrzeniecki
I made a simple test without prism and it works. https://github.com/GWawrzeniecki/JPK/pull/1 Maybe it has to do with PRISM?
Happy coding Tim