Reputation: 6460
I found this style here and add it into my Window.Resources
:
<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>
The problem is that this line:
BasedOn="{StaticResource MahApps.Metro.Styles.ToggleSwitch.Win10}"
got error:
Error 103 The resource "MahApps.Metro.Styles.ToggleSwitch.Win10" could not be resolved.
Any suggestions ?
Upvotes: 3
Views: 7177
Reputation: 1303
If you want to use the style provided by MahApps, you would simply need to modify the ToggleSwitch to add the Style attribute as follows:
<Controls:ToggleSwitch Style="{StaticResource MahApps.Metro.Styles.ToggleSwitch.Win10}" />
Upvotes: 3
Reputation: 169220
Install MahApps using NuGet (Tools->NuGet Package Manager->Package Manager Console in Visual Studio): http://mahapps.com/guides/quick-start.html
And merge the Styles/Controls.ToggleSwitch.xaml
resource dictionary into :
<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>
Upvotes: 4