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

Ajay Gera 40 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">
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,788 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,232 questions
C#
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.
11,065 questions
Visual Studio Extensions
Visual Studio Extensions
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Extensions: A program or program module that adds functionality to or extends the effectiveness of a program.
231 questions
{count} votes

Your answer

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