我喜欢的方式,Windows Phone的项目加载默认的资源,如这些的:默认情况下,WindowsPhone项目是如何加载资源的?
<phone:PhoneApplicationPage
x:Class="PhoneApp4.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
...
PhoneFontFamilyNormal,PhoneFontSizeNormal,PhoneForegroundBrush。因为我为WPF创建了许多库,并且它们都包含一个公共库,并且我在加载该库时正在考虑加载默认情况下的样式资源。
我该如何实现这种方式?
顺便说一下,我正在与WPF合作。
您的解决方案将无法工作。在Foreground中设置=“{StaticResource MyBrush}”。另一个问题是,在设计时,组件不会看到。理想的是在xaml代码中定义资源。 –