1

在将 MahApps.Metro 样式添加到我的资源字典时,我注意到这些样式正在应用于我的应用程序中的所有项目,这不是预期的效果。我只想使用 ToggleSwitch 和 Combobox 样式。如何做到这一点?

谢谢!

4

1 回答 1

4

仅将以下资源字典放入您的 xaml

<ResourceDictionary>
  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" />
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.Buttons.xaml" />
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.ComboBox.xaml" />
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
  </ResourceDictionary.MergedDictionaries>

  <Style TargetType="ToggleButton" BasedOn="{StaticResource MetroToggleButton}" />
  <Style TargetType="ComboBox" BasedOn="{StaticResource MetroComboBox}" />
  <Style TargetType="ComboBoxItem" BasedOn="{StaticResource MetroComboBoxItem}" />
</ResourceDictionary>

希望这可以帮助

于 2012-11-13T09:51:04.003 回答