2012-04-02 27 views
2

我跟着wpf中的擴張器的例子。工作正常,但舊的子彈仍然表現出新的子彈。代碼如下:擴張器舊的子彈仍然顯示

<Expander Name="ExpanderControl" 
    HorizontalAlignment="Left" Background="LavenderBlush" 
    ExpandDirection="Down" IsExpanded="False" Width="250" 
     FontSize="20" FontWeight="Bold" Foreground="Green" > 
<Expander.Header> 
    <BulletDecorator> 
     <BulletDecorator.Bullet> 
      <Image Width="50" Source="Flowers.jpg"/> 
     </BulletDecorator.Bullet> 
     <TextBlock Margin="20,0,0,0">Flower Header</TextBlock> 
    </BulletDecorator> 
</Expander.Header> 

<TextBlock TextWrapping="Wrap" FontSize="14" FontWeight="Light" Foreground="Black"> 
    This is an Expander control. Within this control, all contents will be wrapped. 
    At run-time, you may expand or collapse this control. Type more text here to be   
    Jump around and hype. 
</TextBlock> 
</Expander> 

回答

0

我發現了一個workarround它。

<BulletDecorator.Bullet> 
     <Image Width="50" Source="Flowers.jpg" Margin="-20,0,0,0"/> 
</BulletDecorator.Bullet> 

根據您的需要放置-20的保證金,它會覆蓋舊的子彈。我知道這不是做這件事的正確方法,但它對我有用。

2

ControlTemplateExpander控制限定ToggleButton其內容結合到Header屬性模板。此ToggleButton也有一個ControlTemplate定義,以便有2個列:一個用於Ellipse(和箭頭表示爲Path),另一個用於ContentPresenter(其承載內容Header)。

要更改此行爲,您需要重新定義Expander上的Template屬性。