2017-03-13 14 views
0

10勝を追加する方法を私はこのスタイルhereを発見し、中にそれを追加私のWindow.ResourcesWPF ToggleSwitch:スタイル

<Style x:Key="Custom.ToggleSwitch.Win10" 
     BasedOn="{StaticResource MahApps.Metro.Styles.ToggleSwitch.Win10}" 
     TargetType="{x:Type Controls:ToggleSwitch}"> 
    <Setter Property="Padding" Value="0 0 10 0" /> 
    <Style.Triggers> 
     <Trigger Property="ContentDirection" Value="RightToLeft"> 
      <Setter Property="Padding" Value="10 0 0 0" /> 
     </Trigger> 
    </Style.Triggers> 
</Style> 

問題があり、このラインその:

BasedOn="{StaticResource MahApps.Metro.Styles.ToggleSwitch.Win10}" 

ましたエラー:

Error 103 The resource "MahApps.Metro.Styles.ToggleSwitch.Win10" could not be resolved.

提案がありますか?

+0

は、あなたが持っているあなたは確かにありますMahappsの最新バージョンですか? ResourceDictionary – lokusking

+0

の下部にある[ソースへの直接リンク](https://github.com/MahApps/MahApps.Metro/blob/develop/src/MahApps.Metro/MashApps.Metro/Styles/Controls.ToggleSwitch.xaml)何をどこでコピーする必要がありますか? – user979033

+0

あなたのプロジェクトにMahAppsが参照されていますか? – lokusking

答えて

2

NuGet(Visual Studioで[ツール] - > [NuGetパッケージマネージャ - >パッケージマネージャコンソール)を使用してMahAppsをインストールしますhttp://mahapps.com/guides/quick-start.html

とにStyles/Controls.ToggleSwitch.xamlリソースディクショナリをマージ:

<Window.Resources> 
    <ResourceDictionary> 
     <ResourceDictionary.MergedDictionaries> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.ToggleSwitch.xaml" /> 
     </ResourceDictionary.MergedDictionaries> 
     <Style x:Key="Custom.ToggleSwitch.Win10" 
       BasedOn="{StaticResource MahApps.Metro.Styles.ToggleSwitch.Win10}" 
       TargetType="{x:Type Controls:ToggleSwitch}"> 
      <Setter Property="Padding" Value="0 0 10 0" /> 
      <Style.Triggers> 
       <Trigger Property="ContentDirection" Value="RightToLeft"> 
        <Setter Property="Padding" Value="10 0 0 0" /> 
       </Trigger> 
      </Style.Triggers> 
     </Style> 
    </ResourceDictionary> 
</Window.Resources> 
関連する問題