私はかなり大きなリソースディクショナリを含むクラスライブラリを持っています、そして私は自分のプロジェクトの組織が色のための1つのコントロールスタイルのようなより小さなより特定のファイルに分割することで改善できると思います。私の問題は、辞書の一部が他のフィールドを使用していることです(たとえば、コントロールスタイルで色を使用しています)。1つのリソース辞書を2つに分割できますか?
私の質問は、1つのリソース辞書を2つに分割し、次に1つの辞書を別の言語で使用する方法です。ここで
(分離されていない)のような完全な辞書が見えるか(の一部)である
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<SolidColorBrush x:Key="backgroundColour" Color="#FF1D1D1D"/>
<SolidColorBrush x:Key="foregroundColour" Color="#FFEAEAEA"/>
<SolidColorBrush x:Key="textColour" Color="White"/>
<SolidColorBrush x:Key="borderColour" Color="#FFF31515"/>
<SolidColorBrush x:Key="mouseOverBackgroundColour" Color="#E59400"/>
<SolidColorBrush x:Key="mouseOverForegroundColour" Color="White"/>
<SolidColorBrush x:Key="mousePressedBackgroundColour" Color="OrangeRed"/>
<SolidColorBrush x:Key="mousePressedForegroundColour" Color="White"/>
<Style x:Key="DriveButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Background" Value="{DynamicResource backgroundColour}" />
<Setter Property="Foreground" Value="{DynamicResource foregroundColour}" />
<Setter Property="FontSize" Value="16" />
<Setter Property="FontFamily" Value="Calibri Light" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Margin" Value="2" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}" BorderBrush="Gray" BorderThickness="1" >
<ContentPresenter x:Name="MyContentPresenter" Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{DynamicResource mouseOverBackgroundColour}" />
<Setter Property="Foreground" Value="{DynamicResource mouseOverForegroundColour}" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="{DynamicResource mousePressedBackgroundColour}" />
<Setter Property="Foreground" Value="{DynamicResource mousePressedForegroundColour}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="DriveImageStyle" TargetType="{x:Type Image}">
<Setter Property="Width" Value="30" />
<Setter Property="Height" Value="30" />
<Setter Property="Margin" Value="2" />
<Setter Property="HorizontalAlignment" Value="Left" />
</Style>
<Style x:Key="DriveLabelStyle" TargetType="{x:Type Label}">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="Foreground" Value="{DynamicResource foregroundColour}" />
<Setter Property="FontSize" Value="15" />
<Setter Property="FontFamily" Value="Calibri Light" />
</Style>
あなたの辞書の見た目はわかりませんが、明確な答えを出すのは難しいですが、 ' 'を使って調べましたか? –
Shaamaan
Merged Dictionariesを調べます。私はそれらが2つの別々の*辞書の部分を使用したいところで使用されることが意図されていると思った。私は分割しようとしている辞書のサンプルを追加しました。 – Timmoth
大丈夫、助けてくれてありがとうShaamaan。私はそれが今働いていると思う。 MergedDictionariesがキーになっています... – Timmoth