Changing window properties in Visual C# from code-behind (WPF) -
i want background of wpf window change in specific situation (but other property). let's suppose name of window mywindow1
. if treat window other item (like in windows forms), mywindow1 doesn't seem have background property set; read-only properties shown in auto-complete. if try creating new object this: mywindow1 w1 = new mywindow1();
w1 seems have right properties available changing in autocomplete, including background, , ide shows no errors. when try starting program, hangs.
what doing wrong, , best practice changing wpf windows properties code-behind in visual c# 2013?
try xaml.
< window x:class="wpf1.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" height="350" width="525" > <grid background="{dynamicresource {x:static systemcolors.inactivecaptiontextbrushkey}}"> </grid>
this dynamic resource
<window x:class="wpf1.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" background="{dynamicresource windowbrush}" title="mainwindow" height="350" width="525" > <window.resources> <solidcolorbrush x:key="windowbrush" color="lightgray"/> </window.resources> <grid > </grid> </window>
it done static resource
Comments
Post a Comment