Skip to content

Sometimes, the drawer does not display at all. #3829

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

Open
q913777031 opened this issue Apr 14, 2025 · 1 comment
Open

Sometimes, the drawer does not display at all. #3829

q913777031 opened this issue Apr 14, 2025 · 1 comment
Labels
bug evaluation required Items is pending review or evaluation by the team

Comments

@q913777031
Copy link

Bug explanation

Image

Issue: I'm using WPF with MaterialDesign in XAML, and I've encountered an issue with the Drawer component. Sometimes, the drawer MVVM does not display at all. However, when I modify the binding mode (e.g., set it to two-way binding) and trigger a hot reload, the drawer displays correctly.

I suspect this might be a UI refresh issue, but I'm unsure of the cause. The problem happens intermittently, and only the drawer component seems to be affected. Other parts of the UI are unaffected.

Has anyone experienced a similar issue, or could you provide insights on how to ensure the drawer reliably updates its state and displays correctly?

Version

4.5.0

@q913777031 q913777031 added bug evaluation required Items is pending review or evaluation by the team labels Apr 14, 2025
@corvinsz
Copy link
Member

@q913777031 I can't reproduce your problem using the 4.5.0 version.
Can you share a repo showcasing this bug?
Alternatively, if that's an option, you can try to upgrade to the latest version. However, depending on how big your codebase is, this is a bit of work because there were some breaking changes in the 5.0.0 version.

For reference, here is the setup I have tried to reproduce your problem with:
MainWindow.xaml

<Window x:Class="MDIX3829.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:local="clr-namespace:MDIX3829"
        xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        Title="MainWindow"
        Width="800"
        Height="450"
        Style="{StaticResource MaterialDesignWindow}"
        mc:Ignorable="d">
    <materialDesign:DrawerHost IsRightDrawerOpen="{Binding IsRightDrawerOpen}">
        <materialDesign:DrawerHost.RightDrawerContent>
            <StackPanel>
                <TextBlock Text="Right Drawer Content" />
                <Button Command="{Binding ToggleRightDrawerCommand}" Content="Toggle Drawer" />
            </StackPanel>
        </materialDesign:DrawerHost.RightDrawerContent>
        <Grid HorizontalAlignment="Center">
            <TextBlock Text="Main Content" />
            <Button Command="{Binding ToggleRightDrawerCommand}" Content="Toggle Drawer" />
        </Grid>
    </materialDesign:DrawerHost>
</Window>

MainWindow.xaml.cs

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System.Windows;

namespace MDIX3829;

/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
	public MainWindow()
	{
		InitializeComponent();
		this.DataContext = new MyVM();
	}
}

public partial class MyVM : ObservableObject
{
	[ObservableProperty]
	private bool _isRightDrawerOpen = true;

	[RelayCommand]
	private void ToggleRightDrawer()
	{
		IsRightDrawerOpen = !IsRightDrawerOpen;
	}
}

The following 2 nuget packages are required:

<PackageReference Include="MaterialDesignThemes" Version="4.5.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug evaluation required Items is pending review or evaluation by the team
Projects
None yet
Development

No branches or pull requests

2 participants