Xaml app resource value
1 answer
My brain hurts a little after reading this question. Let me answer as if I really understand what you are asking.
<Application x:Class="WpfApplication1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Window1.xaml">
<Application.Resources>
<Style TargetType="TextBox">
<Setter Property="FontSize" Value="100"/>
</Style>
</Application.Resources>
</Application>
With clarification:
<Application x:Class="WpfApplication1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
StartupUri="Window1.xaml">
<Application.Resources>
<sys:Double x:Key="MyTextHeight">32</sys:Double>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="{StaticResource MyTextHeight}"/>
</Style>
</Application.Resources>
</Application>
notice line 4, then a new Double (also note that the type must match the type of the parameter - I initially tried sys: Int32 which resulted in some interesting unrelated exceptions).
+1
a source to share