Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,20 @@ public Appearance Appearance
using (LayoutTransaction.CreateTransactionIf(AutoSize, ParentInternal, this, PropertyNames.Appearance))
{
_appearance = value;

// UpdateOwnerDraw synchronizes control styles with the OwnerDraw state and recreates
// the handle if they differ. Since we hijack FlatStyle.Standard for DarkMode, the transition
// between Normal and Button appearance is critical for updating the OwnerDraw flag.
UpdateOwnerDraw();

// If handle wasn't recreated (OwnerDraw state didn't change), refresh the appearance.
if (OwnerDraw)
{
Refresh();
}
else
{
UpdateStyles();

// UpdateStyles should also update the UserDraw flag, but it doesn't.
// Since we hijack FlatStyle.Standard for DarkMode and let that SystemRender,
// the threshold from Normal to Button is important to update the OwnerDraw flag.
UpdateOwnerDraw();
}

OnAppearanceChanged(EventArgs.Empty);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,18 @@ public Appearance Appearance
using (LayoutTransaction.CreateTransactionIf(AutoSize, ParentInternal, this, PropertyNames.Appearance))
{
_appearance = value;

// UpdateOwnerDraw checks if OwnerDraw state changed and calls RecreateHandle if needed.
UpdateOwnerDraw();

// If handle wasn't recreated (OwnerDraw state didn't change), refresh the appearance.
if (OwnerDraw)
{
Refresh();
}
else
{
UpdateStyles();

// UpdateStyles should also update the UserDraw flag, but it doesn't.
UpdateOwnerDraw();
}

OnAppearanceChanged(EventArgs.Empty);
Expand Down