Theming of WPF dialog not working for all controls on the dialog

Ajay Gera 45 Reputation points
2024-10-04T14:07:53.0266667+00:00

Hi,

I need to change color/theme of all controls on WPF dialog whenever there is change of theme from VS2022 (i.e. Tools -> Options -> Color Theme )

I followed below MSDN article

https://learn.microsoft.com/en-us/visualstudio/extensibility/vsix/recipes/use-themes?view=vs-2022

As per article, I download project from github - https://github.com/VsixCommunity/Community.VisualStudio.Toolkit/tree/master

Build the project - Community.VisualStudio.Toolkit.17.0 and used generated assembly Community.VisualStudio.Toolkit.dll

I observed issues like - content of textbox control are not visible , combo box control background does not change with theme etc.

Is there any issue with this article or there is any other recommend way to change color of all different types of control on the dialog when the theme changes?

Following is code snippet of dialog window

<platformUI:DialogWindow

		 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

         xmlns:platformUI="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.15.0"

         xmlns:System="clr-namespace:System;assembly=mscorlib"

         xmlns:draw="clr-namespace:System.Drawing;assembly=System.Drawing"

         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Name="m_vabc" x:Class="class1"    

         Title="test" 

         ShowInTaskbar="False"

         WindowStartupLocation="CenterOwner" 

         HorizontalAlignment="Left" VerticalAlignment="Top" 

         ScrollViewer.VerticalScrollBarVisibility="Auto" 

         ScrollViewer.HorizontalScrollBarVisibility="Auto" 

         HorizontalContentAlignment="Center" 

         VerticalContentAlignment="Center" 

         Height="640"

         Width="580"

         DataContext="{Binding RelativeSource={RelativeSource Mode=Self}, Path=<someObject>, Mode=OneWay}" 

         ResizeMode="NoResize" 

         SizeToContent="WidthAndHeight"

         SnapsToDevicePixels="True"

         Loaded="OnLoaded"

		 xmlns:toolkit="clr-namespace:Community.VisualStudio.Toolkit;assembly=Community.VisualStudio.Toolkit"

		 toolkit:Themes.UseVsTheme="True">
Developer technologies | Windows Presentation Foundation
Developer technologies | Visual Studio | Extensions
Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other
A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.
Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.