在Silvelight 5中在DateTemplate中应用全局样式 [英] Apply global style in DateTemplate in silvelight 5
问题描述
嗨
请看这个样本.
我有一个Silverlight项目.它具有与app.xaml合并的样式文件
我的全球风格:
Hi
Please look at this sample.
I have a silverlight project. it has a style file that merged with app.xaml
My global style :
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="TextBlock">
<Setter Property="FontFamily" Value="Tahoma" />
</Style>
</ResourceDictionary>
我将其合并到app.xaml:
I Merged it to app.xaml :
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="SilverlightApplication1.App"
>
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Style.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
它具有一个MainPage:
It has a MainPage :
<UserControl x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" removed="White">
<TextBlock Height="23" HorizontalAlignment="Left" Margin="41,51,0,0" Name="textBlock1" Text="ABC" VerticalAlignment="Top" />
<Button Height="23" HorizontalAlignment="Left" Margin="41,80,0,0" Name="button1" VerticalAlignment="Top" Width="75" >
<Button.Template>
<ControlTemplate>
<Border>
<TextBlock Text="ABC" />
</Border>
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
</UserControl>
在我的MianPage中,我有一个textBlock和一个带有Template的按钮.
我的全局样式适用于TextBlock,但不适用于
的textblock
在按钮的DateTemplete中.
如何解决将全局样式应用于DataTemplte上的元素的问题?
非常感谢
in My MianPage I have a textBlock and a button with Template.
My global style apply on the TextBlock but do not apply on textblock that is
in the DateTemplete for button.
How can I solve this problem that global style apply on the element on DataTemplte ?
Thanls a lot
推荐答案
对不起,我现在就进去了:
http://stackoverflow.com/questions/1786031/Apply-a-fontfamily-to-all-controls-in-silverlight-4-beta [
Sorry, I thionk I got in now:
http://stackoverflow.com/questions/1786031/applying-a-fontfamily-to-all-controls-in-silverlight-4-beta[^]
And this code would make them equal:
<Style TargetType="Button">
<Setter Property="FontFamily" Value="Webdings" />
</Style>
<Style TargetType="TextBlock">
<Setter Property="FontFamily" Value="Webdings" />
</Style>
这篇关于在Silvelight 5中在DateTemplate中应用全局样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!