wpf - MahApps Metro setting Window Border styles from App Resources -
i trying set window border styles mahapps metro app. have read articles how set different border styles , think it. however, trying set border style windows in app same (all drop shadow) , doesn't seem want work.
i have app resources this:
<application.resources> <resourcedictionary> <resourcedictionary.mergeddictionaries> <resourcedictionary source="pack://application:,,,/gsdxthemes;component/gsdxdarkyellowtheme.xaml" /> </resourcedictionary.mergeddictionaries> </resourcedictionary> </application.resources>
my resource dictionary looks this:
<!-- merge in resourcedictionaries defining base of operations styles use. theme based on metro dark yellowish theme. --> <resourcedictionary.mergeddictionaries> <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/colors.xaml" /> <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/fonts.xaml" /> <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/controls.xaml" /> <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/accents/yellow.xaml" /> <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/accents/basedark.xaml" /> <resourcedictionary source="pack://application:,,,/gsdxthemes;component/gsdxcontrolstyles.xaml" /> </resourcedictionary.mergeddictionaries>
the gsdxcontrolstyles dictionary sets custom style values app. in file seek set window borders.
<resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:resx="clr-namespace:gsdxthemes.properties" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:system;assembly=mscorlib" xmlns:controls="clr-namespace:mahapps.metro.controls;assembly=mahapps.metro" xmlns:gsdusercontrols="clr-namespace:gsd.commongui.usercontrols;assembly=commongui"> <resourcedictionary.mergeddictionaries> <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/controls.xaml" /> </resourcedictionary.mergeddictionaries> <!-- customize theme our use...mostly changing font sizes, etc...--> <style targettype="{x:type controls:metrowindow}" > <setter property="windowtransitionsenabled" value="false" /> <setter property="enabledwmdropshadow" value="true" /> </style> <style targettype="{x:type label}" basedon="{staticresource metrolabel}"> <setter property="fontsize" value="16"/> </style> <style targettype="{x:type textbox}" basedon="{staticresource metrotextbox}"> <setter property="fontsize" value="16"/> </style> ...
all other style settings work fine. first line setting window border nothing. windows show no border.
how can work windows have drop shadow border?
you must give style key working solution
<style x:key="customdefaultwindowstyle" targettype="{x:type controls:metrowindow}" basedon="{staticresource {x:type controls:metrowindow}}" > <setter property="windowtransitionsenabled" value="false" /> <setter property="enabledwmdropshadow" value="true" /> </style>
now utilize style on metrowindow
s
<controls:metrowindow x:class="yourwindowclass" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:mahapps.metro.controls;assembly=mahapps.metro" xmlns:system="clr-namespace:system;assembly=mscorlib" title="custom window style demo" height="600" width="800" windowstartuplocation="centerscreen" style="{dynamicresource customdefaultwindowstyle}"> ... </controls:metrowindow>
(don't afraid of the'invalid style target type:...' message, it's vs bug)
hope helps
wpf mahapps.metro
No comments:
Post a Comment