Skip to content

Commit 3fa5fe4

Browse files
Leaf ShiLeaf Shi
authored andcommitted
Add judgement "IsDarkModeEnabled" for property BackgroundImage
1 parent 6377f2e commit 3fa5fe4

File tree

1 file changed

+6
-3
lines changed
  • src/System.Windows.Forms/System/Windows/Forms/Controls/Buttons

1 file changed

+6
-3
lines changed

src/System.Windows.Forms/System/Windows/Forms/Controls/Buttons/Button.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,12 @@ public override Image? BackgroundImage
154154
{
155155
base.BackgroundImage = value;
156156

157-
// BackgroundImage changes may affect rendering logic,
158-
// so we manually update the OwnerDraw flag to ensure correct visual behavior.
159-
UpdateOwnerDraw();
157+
if (Application.IsDarkModeEnabled)
158+
{
159+
// BackgroundImage changes may affect rendering logic,
160+
// so we manually update the OwnerDraw flag to ensure correct visual behavior.
161+
UpdateOwnerDraw();
162+
}
160163
}
161164
}
162165

0 commit comments

Comments
 (0)