c# - Setting Look and Feel -


i have following lafs ("look , feel" ,from java's swing) in 2 different projects :

type 1 :

enter image description here

type 2 :

enter image description here

i know how can switch between these , other lafs. in advance.

the easiest, maintainable method i'm aware of swapping in different visual styles use styles in external resourcedictionary. example below create new solution folder called 'skins', add new class called 'mainskin.xaml'.

mainwindow.xaml

<window.resources>     <resourcedictionary>         <resourcedictionary.mergeddictionaries>             <resourcedictionary source="skins/mainskin.xaml" />         </resourcedictionary.mergeddictionaries>     </resourcedictionary> </window.resources>  <grid>     <textblock style="{staticresource textblockv1}" text="this text." /> </grid> 

skins\mainskin.xaml

<resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">      <style x:key="textblockv1" targettype="textblock">         <setter property="horizontalalignment" value="center" />         <setter property="fontfamily" value="comic sans ms" />         <setter property="fontsize" value="14" />     </style>      <style x:key="textblockv2" targettype="textblock">         <setter property="horizontalalignment" value="right" />         <setter property="fontfamily" value="courier new" />         <setter property="fontsize" value="30" />     </style>      <style x:key="textblockv3" targettype="textblock">         <setter property="horizontalalignment" value="left" />         <setter property="fontfamily" value="times new roman" />         <setter property="fontsize" value="8" />     </style>  </resourcedictionary> 

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Website Login Issue developed in magento -

Can the constants be defined inside a model file of a framework in PHP? -