2016-08-14 1 views
2

How do i achive this?MahApps CleanWindowを動作させるには?私はタイトルにCleanWindowを持ちたい

、私はWPFに新たなんだので、私は本当にこの

に苦労ここMainWindow.xamlのためのコードです:

<Controls:MetroWindow x:Class="Twitch_Notifier.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:local="clr-namespace:Twitch_Notifier" 
    mc:Ignorable="d" 
    TitleCaps="False" 
    ShowTitleBar="True" 
    ShowIconOnTitleBar="False" 
    ResizeMode="CanMinimize" 
    Title="Twitch Notifier" Height="350" Width="525" WindowStartupLocation="CenterScreen" 
    GlowBrush="{DynamicResource AccentColorBrush}" 
    Style="{DynamicResource CleanWindowStyleKey}"> 

<Window.Resources> 
    <ResourceDictionary> 
     <ResourceDictionary.MergedDictionaries> 
      <ResourceDictionary Source="/Resources/Icons.xaml" /> 
     </ResourceDictionary.MergedDictionaries> 
    </ResourceDictionary> 
</Window.Resources> 

<Controls:MetroWindow.RightWindowCommands> 
    <Controls:WindowCommands> 
     <Button Content="settings" /> 
    </Controls:WindowCommands> 
</Controls:MetroWindow.RightWindowCommands> 

<Grid> 

</Grid> 

But i get this error

コードfor App.xaml:

<Application x:Class="Twitch_Notifier.App" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:local="clr-namespace:Twitch_Notifier" 
     StartupUri="MainWindow.xaml"> 
<Application.Resources> 
    <ResourceDictionary> 
     <ResourceDictionary.MergedDictionaries> 
      <!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! --> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" /> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" /> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" /> 
      <!-- Accent and AppTheme setting --> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" /> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" /> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Clean/Clean.xaml" /> 
     </ResourceDictionary.MergedDictionaries> 
    </ResourceDictionary> 
</Application.Resources> 

私はこれをどのように修正することができますか?おかげであなたの助け

答えて

1

のためにそれはa limitation of the designerだが、回避策は単純です:

1))MyCleanWindowStyle(参考にMetroWindowスタイルにウィンドウスタイルをキャスト

2)の代わりに

MetroWindowスタイルを適用します。
<Controls:MetroWindow 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:local="clr-namespace:Views;assembly=gasby.Wpf" 
     xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" 
     ShowTitleBar="True" ShowIconOnTitleBar="False" ResizeMode="CanMinimize" 
     Title="CleanWindow" Height="350" Width="525" WindowStartupLocation="CenterScreen" 
     GlowBrush="{DynamicResource AccentColorBrush}" 
     Style="{DynamicResource MyCleanWindowStyle}"> 
    <Controls:MetroWindow.Resources> 
     <ResourceDictionary> 
      <Style x:Key="MyCleanWindowStyle" 
        TargetType="{x:Type Controls:MetroWindow}" 
        BasedOn="{StaticResource CleanWindowStyleKey}"/> 

      ... 

     </ResourceDictionary> 
    </Controls:MetroWindow.Resources> 

    ... 

    <Grid> 
    </Grid> 
</Controls:MetroWindow> 

あなたはタイトルを設定したいと言いますが、これはコードTitle="CleanWindow"によって行われます。 TitleCapsプロパティは、タイトルがすべて大文字(CAPital文字)で表示されるかどうかを決定します。 デフォルトはTitleCaps="True"です。

関連する問題