カスタマイズWPFエキスパンダー。のみクリックできない全体のヘッダアイコン作ります

StackOverflow https://stackoverflow.com/questions/2822288

  •  26-09-2019
  •  | 
  •  

質問

私だけ拡大Expanderをしたい/それの内容を折りたたむ際に、ヘッダーのアイコンをユーザーがクリックします。 (代わりに、全体ヘッダーがクリック可能であるという。)

ドゥ私はこれを行うための制御Templateを再定義する必要がありますか?それはどのように?
ようになります。 どこでコントロールするための標準的なテンプレート/スタイルを見つけることができますか?

あなたの時間をありがとうます。

役に立ちましたか?

解決 2

私は私の質問に対する解決策はここにhref="https://stackoverflow.com/questions/1396153/preventing-a-wpf-expander-from-expanding-when-header-is-clicked"> (ベンからのコメントと同じリンク)。

他のヒント

テンプレートを修正するよりもはるかに簡単なXAMLソリューションは、実際にあります。単純に、この場合にはパンダのヘッダープロパティを使用しないでください。代わりに、独自のスタイル付きのTextBlockとエクスパンダをカバーします。

<Application.Resources>
    <Style x:Key="ExpanderHeader" TargetType="{x:Type TextBlock}">
        <Setter Property="Height" Value="22" />
        <Setter Property="Margin" Value="21,0,0,0" />
        <Setter Property="Padding" Value="9,3,0,0" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Top" />
    </Style>
</Application.Resources>

<Grid>
    <Expander>
        <TextBlock Text="I am some content. I have disowned my default header." Margin="10,5" />
    </Expander>
    <TextBlock Text="I'm filling in for the default header. You'll like me better anyway."
               Style="{StaticResource ResourceKey=ExpanderHeader}"/>
</Grid>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top