c# - Styling all instances of a derived type in WPF -
i have class named mywindow
derives window
:
using system.windows; public class mywindow : window { }
and use class in mainwindow.xaml
:
<mywpfapp:mywindow x:class="mywpfapp.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:wpfapplication1="clr-namespace:wpfapplication1" title="mainwindow" height="350" width="525"> <grid> <textblock text="test" foreground="orange"/> </grid> </mywpfapp:mywindow>
and in app.xaml
file, add following style override background
property of mywindow
instances:
<application.resources> <style targettype="mywpfapp:mywindow"> <setter property="background" value="black"></setter> </style> </application.resources>
but doesn't change @ all. no style applied mainwindow
.
what should can use global style mywindow
s?
p.s.: checked out "modern ui"s code, saw apply following in window's constructor:
using system.windows; public class mywindow : window { public mywindow() { defaultsylekey = typeof (mywindow); } }
but if this, mainwindow ends being black in content area. guessing somehow template
property gets overriden, don't understand how, , how make work.
ok have worked out. apparently there's special file can use named generic.xaml
.
you need add style definitions there , add file directory called themes
.
wpf end using fall back: themes\generic.xaml
Comments
Post a Comment