2017-09-06 8 views
0

これはWPF GroupBoxのスタイルです。 グループボックスの背景とグループボックスの境界線の値を、App.xaml.csで定義されているプロパティから設定することができます。App.xaml.csのプロパティを使用してGroupBoxヘッダーテンプレートのForegroundを設定します。

<Style x:Key="StyleGroupBox1" TargetType="GroupBox"> 
      <Setter Property="Background" > 
       <Setter.Value> 
        <Binding Path="GroupBox_Background" Source="{x:Static Application.Current}"/> 
       </Setter.Value> 
      </Setter> 
      <Setter Property="BorderBrush"> 
       <Setter.Value> 
        <Binding Path="Groupbox_BorderColor" Source="{x:Static Application.Current}"/> 
       </Setter.Value> 
      </Setter> 
      <Setter Property="Margin" Value="1,1,1,1"/> 
      <Setter Property="HeaderTemplate"> 
       <Setter.Value> 
        <DataTemplate> 
         <TextBlock Text="{Binding}" FontWeight="Bold" FontFamily="Palatino Linotype" FontSize="17" Foreground="DarkRed" FontStyle="Italic"> 

         </TextBlock> 

        </DataTemplate> 
       </Setter.Value> 
      </Setter> 
     </Style> 

私は(私のapp.xaml.csで定義されたプロパティからIE)グループボックスの背景とはBorderColorを設定している方法に類似のGroupBoxのヘッダーテンプレートの前景色を設定するには?つまり、現在ヘッダーテキストはDarkRedに設定されていますが、App.xaml.csのプロパティを使用して設定する方法は?

答えて

1
<TextBlock 
       Text="{Binding}" 
       FontWeight="Bold" 
       FontFamily="Palatino Linotype" 
       FontSize="17" 
       Foreground="{Binding Source={x:Static Application.Current}, Path=Groupbox_HeaderForegroundColor}" 
       FontStyle="Italic"> 
+0

Vadim Moskvin:大丈夫..忘れてしまった。うまくいきました。間違ったTargetTypeを使用していました。私の悪い.. :-)。 –

関連する問題