1 回答
TA贡献1786条经验 获得超11个赞
将资源字典合并到您的窗口中:
<Window x:Class="ThemesTesting.ShellWindow"
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"
Height="450" Width="800">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/CommonStyles;component/ButtonStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Button Height="50" Width="100" Content="Click Me" Style="{StaticResource ButtonStyle}"></Button>
</Grid>
</Window>
如果ResourceDictionary定义的程序集称为“CommonStyles”,并且它ResourceDictionary本身被命名为“ButtonStyle.xaml”并且位于CommonStyles项目的根目录中,则这应该有效。
您还需要CommonStyles.dll从ShellWindow定义的项目中添加一个引用。
- 1 回答
- 0 关注
- 159 浏览
添加回答
举报