我正在創建一個Windows Phone 8應用程序。在應用程序中我有一個XAML文件中定義的資源字典爲:如何在Windows Phone 8中使用ResourceDictionary作爲StaticResource(元素不是fount)
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="YellowGreen" />
<Setter Property="FontSize" Value="35" />
<Setter Property="TextWrapping" Value="Wrap"/>
</Style>
<Style TargetType="TextBox" x:Key="CommonSetters">
<Setter Property="Width" Value="450"/>
<Setter Property="FontSize" Value="35" />
<Setter Property="Foreground" Value="YellowGreen" />
<Setter Property="Height" Value="100"/>
<Setter Property="Background" Value="Red">
<!--<Setter.Value>
<ImageBrush ImageSource="logo.png" Opacity="0.1"/>
</Setter.Value>-->
</Setter>
</Style>
</ResourceDictionary>
這ResourceDictionary的是在App.xaml中引用爲:
的xmlns:SHELL =「CLR的命名空間:微軟.Phone.Shell;裝配= Microsoft.Phone「>
<!--Application Resources-->
<Application.Resources>
<local:LocalizedStrings xmlns:local="clr-namespace:Work_Force" x:Key="LocalizedStrings"/>
<ResourceDictionary x:Key="myDict">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resource.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
<Style TargetType="TextBlock" x:Key="NN">
<Setter Property="Width" Value="450"/>
<Setter Property="FontSize" Value="35" />
<Setter Property="Foreground" Value="YellowGreen" />
<Setter Property="Height" Value="100"/>
</Style>
</Application.Resources>
<Application.ApplicationLifetimeObjects>
<!--Required object that handles lifetime events for the application-->
<shell:PhoneApplicationService
Launching="Application_Launching" Closing="Application_Closing"
Activated="Application_Activated" Deactivated="Application_Deactivated"/>
</Application.ApplicationLifetimeObjects>
</Application>
,然後做的簡單的部分:
靜態資源NN做工精細,但commonSetters沒有工作,那麼在resourse.xaml聲明。
感謝,這也適用 –