I am also having trouble getting my ToolWindow to set the Background color of the Dark theme. I appear to be passing the correct Brush to the WPF UserControl in my ToolWindow. The Window Title styles correctly but not the Background Color. How can I get the background color to match the theme?
public class TestifyCoverageWindow : ToolWindowPane
{
private IVsUIShell5 _shell5;
{
private IVsUIShell5 _shell5;
public TestifyCoverageWindow() :
base(null)
{
Initialize();
// Set the window title reading it from the resources.
this.Caption = Resources.ToolWindowCodeCoverage;
this.BitmapResourceID = 301;
this.BitmapIndex = 1;
var themeRespourceKey = new ThemeResourceKey(new System.Guid("624ed9c3-bdfd-41fa-96c3-7c824ea32e3d"), "ToolWindowBackground", 0);
var themeColor = VsColors.GetThemedWPFColor(_shell5, themeRespourceKey);
var colorBrush = new System.Windows.Media.SolidColorBrush(themeColor);
var colorBrush = new System.Windows.Media.SolidColorBrush(themeColor);
base.Content = new SummaryViewControl(this, colorBrush);
}
}
protected override void Initialize()
{
_shell5 = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsUIShell)) as IVsUIShell5;
{
_shell5 = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsUIShell)) as IVsUIShell5;
}
Then in my ViewModel I do this...
private void BuildCoverageViewModel()
{
_coverageViewModel = GetSummaries(_context);
{
_coverageViewModel = GetSummaries(_context);
if (_coverageViewModel.Modules.Count > 0)
{
this.Dispatcher.Invoke((Action)(() =>
{
this.Background = _brush;
base.Background = _brush;
treeGrid.Background = _brush;
base.DataContext = _coverageViewModel;
treeGrid.DataContext = _coverageViewModel;
{
this.Dispatcher.Invoke((Action)(() =>
{
this.Background = _brush;
base.Background = _brush;
treeGrid.Background = _brush;
base.DataContext = _coverageViewModel;
treeGrid.DataContext = _coverageViewModel;
}));
}
else
{
base.Content = "Waiting for Solution to be Built";
}
}