Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

How to have Visual Studio Extension's controls extend the VS theme

$
0
0

I've built a Visual Studio Extension called Diff All Files.  This extension adds a new section to the Team Explorer's Pending Changes window (as well as others), and has some buttons, labels, and combo boxes on it.  The controls look fine if the default Light theme, but don't switch colors when the user changes to the Dark theme, so they stand out like a sore thumb.

I found this post which mentions that if you don't apply a style to your controls, they should automatically inherit the theme's style, and they do.  My problem is that I want to apply additional style attributes on my controls to adjust the Margins, length of time that ToolTips are displayed for, etc.  So I have this in my User Control's xaml:

<UserControl.Resources><Style TargetType="{x:Type Button}"><Setter Property="ToolTipService.ShowDuration" Value="60000" /><Setter Property="Padding" Value="5,2,5,2" /><Setter Property="Margin" Value="0,2,5,2" /><Setter Property="Height" Value="25" /><Setter Property="VerticalAlignment" Value="Center" /></Style>
	...</UserControl.Resources>

If I get rid of this UserControl.Resources section then the theme's colors are applied to my controls, but I don't want to do this because it means I would have to manually specify these additional attributes on every single Button that I define.  I was hoping there would be away to simply build off of the inherited style.

I found this Stack Overflow post asking the same question, but their given answer of using the BasedOn property doesn't seem to work for my case.  If I change my line above to the following, it still completely overwrites the VS theme's style:

<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">

Any ideas on how I can simply extend the Visual Studio theme's style for my controls?

Thanks


- Dan - "Can't never could do anything"



Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>