【发布时间】:2020-04-14 08:40:18
【问题描述】:
我有一个这样的网格
<Grid>
<Grid.Resources>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="12px"/>
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="FontStretch" Value="Normal"/>
<Setter Property="FontStyle" Value="Normal"/>
<Setter Property="Foreground" Value="#5D58F7"/>
</Style>
</Grid.Resources>
<uctrl:sr ></uctrl:sr>
</Grid>
哪个工作正常。现在我想将这些样式移动到我的主题文件中。为了实现这一点,我做了这样的事情。
在theme.xaml中
<Style x:Key="mystyleinsidethemefile" TargetType="TextBlock">
<Setter Property="FontSize" Value="12px"/>
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="FontStretch" Value="Normal"/>
<Setter Property="FontStyle" Value="Normal"/>
<Setter Property="Foreground" Value="#5D58F7"/>
</Style>
在我的页面内
<Grid Height="36" >
<Grid.Resources>
<Style TargetType="TextBlock">
<Setter Property="Style" Value="{StaticResource mystyleinsidethemefile}"/>
</Style>
</Grid.Resources>
<uctrl:sr ></uctrl:sr>
</Grid>
我该如何解决这个问题?
【问题讨论】: