2016-10-19 2 views
0

WPFでIAMニュービーと私は再び助けを必要と...パンダスタイル質問

私は角の丸いエキスパンダーを持っている、しかし、私はこれが好きではないと私は長方形のコーナーをしたいです。誰も私にこの問題を解決する方法を教えてもらえますか? これは..スタイル私のエキスパンダー です:

<Style x:Key="exp_AInfo_Style" TargetType="Expander"> 
     <Setter Property="IsExpanded" Value="True"/> 
     <Setter Property="HorizontalAlignment" Value="Left"/> 
     <Setter Property="VerticalAlignment" Value="Top"/> 
     <Setter Property="Margin" Value="18,5,0,0"/> 
     <Setter Property="Width" Value="259"/> 
     <Setter Property="Height" Value="29"/> 
     <Setter Property="FontSize" Value="14"/> 

     <Style.Triggers> 
      <Trigger Property="IsExpanded" Value="True"> 
       <Setter Property="Height" Value="155"/> 
      </Trigger> 
     </Style.Triggers> 
    </Style> 

とオブジェクト:

 <Expander x:Name="exp_AInfo" Header="Allgemeine Info's" 
      Style="{StaticResource exp_AInfo_Style}" Height="116" 
      > 
      <Expander.Background> 
       <ImageBrush ImageSource="pct/expander.png" Opacity="0.9"/> 
      </Expander.Background> 
      <Grid Height="112"> 
       <!--many many objects--> 
      </Grid> 
     </Expander> 

おかげで4ヘルプ

+0

私は私の答えを削除しますが、これはSO投稿し、あなたのニーズに合わせてそれを調整することができるかどうかを確認を参照してくださいました。http://stackoverflow.com/questions/4738711/ label-and-expander-control-with-rounded-cornerers – GEEF

答えて

0

これは、すべてのトグルボタンのControlTemplateのCornerRadiusについてです。そこ

あなたが行く:

<ControlTemplate x:Key="ExpanderToggleButton" 
      TargetType="{x:Type ToggleButton}"> 
     <Border x:Name="Border" 
       CornerRadius="0,0,0,0" 
       BorderThickness="1" Background="White" BorderBrush="Black"> 

      <VisualStateManager.VisualStateGroups> 
       <VisualStateGroup x:Name="CommonStates"> 
        <VisualState x:Name="Normal" /> 
        <VisualState x:Name="MouseOver"> 
        </VisualState> 
        <VisualState x:Name="Pressed"> 
        </VisualState> 
        <VisualState x:Name="Disabled"> 
        </VisualState> 
       </VisualStateGroup> 
       <VisualStateGroup x:Name="CheckStates"> 
        <VisualState x:Name="Checked"> 
         <Storyboard> 
          <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" 
             Storyboard.TargetName="CollapsedArrow"> 
           <DiscreteObjectKeyFrame KeyTime="0" 
            Value="{x:Static Visibility.Hidden}" /> 
          </ObjectAnimationUsingKeyFrames> 
          <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" 
             Storyboard.TargetName="ExpandededArrow"> 
           <DiscreteObjectKeyFrame KeyTime="0" 
            Value="{x:Static Visibility.Visible}" /> 
          </ObjectAnimationUsingKeyFrames> 
         </Storyboard> 
        </VisualState> 
        <VisualState x:Name="Unchecked" /> 
        <VisualState x:Name="Indeterminate" /> 
       </VisualStateGroup> 
      </VisualStateManager.VisualStateGroups> 
      <Grid> 
       <Path x:Name="CollapsedArrow" 
         HorizontalAlignment="Center" 
         VerticalAlignment="Center" 
         Data="M 0 0 L 4 4 L 8 0 Z"> 
        <Path.Fill> 
         <SolidColorBrush Color="Black" /> 
        </Path.Fill> 
       </Path> 
       <Path x:Name="ExpandededArrow" 
        HorizontalAlignment="Center" 
        VerticalAlignment="Center" 
        Visibility="Collapsed" 
        Data="M 0 4 L 4 0 L 8 4 Z"> 
        <Path.Fill> 
         <SolidColorBrush Color="Black" /> 
        </Path.Fill> 
       </Path> 
      </Grid> 
     </Border> 
    </ControlTemplate> 

    <Style TargetType="{x:Type Expander}"> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="{x:Type Expander}"> 
        <Grid> 
         <Grid.RowDefinitions> 
          <RowDefinition Height="Auto" /> 
          <RowDefinition x:Name="ContentRow" 
         Height="0" /> 
         </Grid.RowDefinitions> 
         <VisualStateManager.VisualStateGroups> 
          <VisualStateGroup x:Name="CommonStates"> 
           <VisualState x:Name="Normal" /> 
           <VisualState x:Name="MouseOver" /> 
           <VisualState x:Name="Disabled"/> 
          </VisualStateGroup> 
         </VisualStateManager.VisualStateGroups> 
         <Border x:Name="Border" 
           Grid.Row="0" 
           BorderThickness="1" 
           CornerRadius="2,2,0,0"> 
          <Border.BorderBrush> 
           <LinearGradientBrush EndPoint="0,1" 
           StartPoint="0,0"> 
            <GradientStop Color="White" Offset="0" /> 
            <GradientStop Color="White" Offset="1" /> 
           </LinearGradientBrush> 
          </Border.BorderBrush> 
          <Border.Background> 
           <LinearGradientBrush StartPoint="0,0" 
           EndPoint="0,1"> 
            <LinearGradientBrush.GradientStops> 
             <GradientStopCollection> 
              <GradientStop Color="White" Offset="0.0" /> 
              <GradientStop Color="White" Offset="1.0" /> 
             </GradientStopCollection> 
            </LinearGradientBrush.GradientStops> 
           </LinearGradientBrush> 

          </Border.Background> 
          <Grid> 
           <Grid.ColumnDefinitions> 
            <ColumnDefinition Width="20" /> 
            <ColumnDefinition Width="*" /> 
           </Grid.ColumnDefinitions> 
           <ToggleButton OverridesDefaultStyle="True" 
             Template="{StaticResource ExpanderToggleButton}" 
             IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"> 
            <ToggleButton.Background> 
             <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> 
              <GradientStop Color="White" Offset="0" /> 
              <GradientStop Color="White" Offset="1" /> 
             </LinearGradientBrush> 
            </ToggleButton.Background> 
           </ToggleButton> 
           <ContentPresenter Grid.Column="1" 
            Margin="4" 
            ContentSource="Header" 
            RecognizesAccessKey="True" /> 
          </Grid> 
         </Border> 
         <Border x:Name="Content" 
            Grid.Row="1" 
            BorderThickness="1,0,1,1" 
            CornerRadius="0,0,0,0"> 
          <ContentPresenter Margin="4" /> 
         </Border> 
        </Grid> 
        <ControlTemplate.Triggers> 
         <Trigger Property="IsExpanded" Value="True"> 
          <Setter TargetName="ContentRow" 
           Property="Height" 
           Value="{Binding DesiredHeight, ElementName=Content}" /> 
         </Trigger> 
        </ControlTemplate.Triggers> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 
+0

uuhfffg ...私はソリューションが2行のコードであると予想しています –