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
Post a Comment