開発環境
- VS2017
- .net framework 4.7.1
- c#
モジュール構成
AeroTest.exe - MainWindow.xamlを実装したモジュール
Resources.dll - ResourceDictionaryでstyleを定義したDLL
Resources.dll内で別途スタイルを定義してAeroテーマをボタンなどのデフォルトテーマにしたく指定しているのですが反映されません。
Resources.dll内でAeroテーマをResourceDictionary.MergedDictionariesで追加しても反映されない仕様なのでしょうか。
ちなみにApp.xaml内で直接AeroテーマをMergedDictionariesに追加する分にはうまくいきます。
アセンブリ名:Resources
ソース名:styles.xaml
c#
1<ResourceDictionary 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 4 5 <ResourceDictionary.MergedDictionaries> 6 <ResourceDictionary Source="/PresentationFramework.AeroLite;component/themes/aerolite.normalcolor.xaml" /> 7 </ResourceDictionary.MergedDictionaries> 8 9 10 <Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}"> 11 <Setter Property="Margin" Value="5,5,5,5"/> 12 <Setter Property="VerticalAlignment" Value="Center"/> 13 <Setter Property="VerticalContentAlignment" Value="Center"/> 14 <Setter Property="Height" Value="25"/> 15 </Style> 16</ResourceDictionary>
アセンブリ名:AeroTest
ソース名:App.xaml
c#
1<Application x:Class="AeroTest.App" 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 xmlns:local="clr-namespace:AeroTest" 5 StartupUri="MainWindow.xaml"> 6 <Application.Resources> 7 <ResourceDictionary> 8 <ResourceDictionary.MergedDictionaries> 9 <ResourceDictionary Source="pack://application:,,,/Resources;component/styles.xaml"/> 10 </ResourceDictionary.MergedDictionaries> 11 </ResourceDictionary> 12 </Application.Resources> 13</Application>
アセンブリ名:AeroTest
ソース名:MainWindow.xaml
c#
1<Window x:Class="AeroTest.MainWindow" 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 5 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 6 xmlns:local="clr-namespace:AeroTest" 7 mc:Ignorable="d" 8 Title="MainWindow" Height="450" Width="800"> 9 <StackPanel> 10 <Button Content="ボタン1"/> 11 <Button Content="ボタン2"/> 12 </StackPanel> 13</Window>
回答2件
あなたの回答
tips
プレビュー