c# - WPF Create a kind of "variable" in xaml code in order to use in the rest of xaml code -


i wonder whether in xaml there possibility create "kind" of variable , use rest of xaml code. example, suppose many controls share same width can declare width once in xaml , use in xaml code?

you can define "variables" in resources, prefer use styles, set properties same value:

xmlns:sys="clr-namespace:system;assembly=mscorlib"      <window.resources>     <sys:double x:key="yourvar">30.0</sys:double> </window.resources>  <combobox>                 <combobox.items>         <comboboxitem fontsize="{binding source={staticresource yourvar}}">1</comboboxitem>         <comboboxitem>2</comboboxitem>         <comboboxitem>3</comboboxitem>     </combobox.items> </combobox> 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -