c# - How to change FontFamily for Textbox while defined in Window -
i have issue defining fontfamily textboxes applicationwide, because font family defined @ window level style :
<style targettype="window" > <setter property="fontfamily" value="lucida sans unicode"/> <setter property="fontsize" value="10pt"/> </style>
i have defined font-family textboxes way :
<style targettype="{x:type textbox}"> <setter property="fontfamily" value="arial"/> <setter property="fontsize" value="10pt"/> </style>
however, textbox style not applied, , text textboxes still lucida, , not arial. how can ? there css-like !important equivalent in xaml style override previous 1 ?
i notice appreciate xaml way perform on resourcedictionaries.
thanks answers
it working me. defined 2 styles, 1 window, 1 special text box. special style wins , result arial 30pt. if comment special style window style applied textbox , comic sans 20pt appear.
see code:
<window x:class="wpfapplication3.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:wpfapplication3" title="mainwindow" height="350" width="525"> <grid> <textbox text="hello!"/> </grid> </window>
application resources:
<application x:class="wpfapplication3.app" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" startupuri="mainwindow.xaml"> <application.resources> <style targettype="window" > <setter property="fontfamily" value="comic sans ms"/> <setter property="fontsize" value="20pt"/> </style> <style targettype="{x:type textbox}"> <setter property="fontfamily" value="arial"/> <setter property="fontsize" value="30pt"/> </style> </application.resources> </application>
Comments
Post a Comment