2011-10-18 2 views
1

사용자 지정 ButtonStyle과 함께 ExtendedWPFToolkits의 ColorPicker를 사용하고 싶습니다. 항목의 Template 속성을 재정의하는 새로운 모양을 만들 수 있지만 원래 템플릿 클릭 이벤트가 누락되었습니다.원본 이벤트를 유지하는 새 ControlTemplate 정의

나는 그것을 지키고 싶지만 어떻게해야합니까?

<Controls:ColorPicker > 
    <Controls:ColorPicker.ButtonStyle> 
     <Style TargetType="{x:Type ToggleButton}"> 
      <Setter Property="Template"> 
       <Setter.Value> 
        <ControlTemplate> 
         <Button Content="ColorPicker"></Button> 
        </ControlTemplate> 
       </Setter.Value> 
      </Setter> 
     </Style> 
    </Controls:ColorPicker.ButtonStyle> 
</Controls:ColorPicker> 

답변

2

당신이 가지고있는 것은 유효하지 않습니다. 당신은 ToggleButton의 ControlTemplate에 Button을 넣고 있습니다. 기본적으로 버튼에있는 버튼입니다.

당신은 같은 것을 할 필요가 거라고 :

<Controls:ColorPicker > 
    <Controls:ColorPicker.ButtonStyle> 
     <Style TargetType="{x:Type ToggleButton}"> 
      <Setter Property="Template"> 
       <Setter.Value> 
        <ControlTemplate> 
         <Border Background="Transparent"> 
          <TextBlock Text="ColorPicker" /> 
         </Border> 
        </ControlTemplate> 
       </Setter.Value> 
      </Setter> 
     </Style> 
    </Controls:ColorPicker.ButtonStyle> 
</Controls:ColorPicker> 

나는 투명한 Border 그래서 버튼이 텍스트에 포함되지 영역에 대한 마우스 이벤트를받을 수 있습니다 덧붙였다.

관련 문제