2017-04-20 16 views
0

ICT 이름이 지정된 GoToSheet를 ControlTemplate이있는 Button에 바인딩합니다.ControlTemplate이있는 WPF의 명령이 전체 영역에서 작동하지 않습니다.

<Button Margin="10 10 10 10" Command="{Binding GoToSheet}"> 
    <Button.Template> 
     <ControlTemplate> 
      <DockPanel Width="840"> 
       <Border DockPanel.Dock="Left" BorderBrush="Black" BorderThickness="5"></Border> 
       <Border DockPanel.Dock="Top" BorderBrush="Black" BorderThickness="2"></Border> 
       <Border DockPanel.Dock="Right" BorderBrush="Black" BorderThickness="2"></Border> 
       <Border DockPanel.Dock="Bottom" BorderBrush="Black" BorderThickness="2"></Border> 
       <DockPanel DockPanel.Dock="Left"> 
        <StackPanel Orientation="Vertical" Margin="20 10 0 10"> 
         <StackPanel Orientation="Horizontal"> 
          <StackPanel Orientation="Vertical" Margin="0 0 0 10"> 
           <TextBlock Text="{Binding Client}" FontSize="30" FontWeight="Bold" MaxWidth="480"></TextBlock> 
           <TextBlock Text="{Binding Lieu}" FontSize="22" MaxWidth="480"></TextBlock> 
          </StackPanel> 
          <Image Height="35" Width="45" Margin="7 3 0 0" VerticalAlignment="Top" Source="/Resource/Image/CHC.png"></Image> 
         </StackPanel> 
         <StackPanel Orientation="Vertical" VerticalAlignment="Bottom" Margin="20 0 0 0"> 
          <TextBlock Text="{Binding MarqueEngin}" FontSize="26" FontWeight="Bold"></TextBlock> 
          <TextBlock Text="{Binding ModeleEngin}" FontSize="19" FontWeight="Bold"></TextBlock> 
         </StackPanel> 
        </StackPanel> 
       </DockPanel> 
       <DockPanel DockPanel.Dock="Right" Margin="0 10 20 10"> 
        <TextBlock DockPanel.Dock="Top" Text="{Binding DateIntervention, StringFormat=dd/MM/yyyy}" FontSize="30" HorizontalAlignment="Right"></TextBlock> 
        <TextBlock DockPanel.Dock="Bottom" Text="{Binding NumeroEngin}" VerticalAlignment="Bottom" FontSize="30" FontWeight="Bold" HorizontalAlignment="Right"></TextBlock> 
       </DockPanel> 
      </DockPanel> 
     </ControlTemplate> 
    </Button.Template> 
</Button> 

명령은 성공의 영역에서 작동하는 이유 (image 참조)? 전체 단추 영역에서 명령이 작동하는 솔루션이 있습니까?

답변

0

투명 배경은 Button 대신 DockPanel에 있어야합니다.

<Button Margin="10 10 10 10" Command="{Binding GoToSheet}"> 
     <Button.Template> 
      <ControlTemplate> 
       <DockPanel Width="840" Background="Transparent"> 

macieqqq에게 감사드립니다.

1

배경 부족 (버튼 배경이 NULL 임)으로 인해 발생합니다. 예를 들어, 어떤 색상 배경을 설정하십시오 :

여기
<Button Margin="10 10 10 10" Background="Transparent" Command="{Binding GoToSheet}"> 

가 비슷한 문제에 대한 솔루션입니다 : 그것은 도움이 될 것입니다

Mouse event on transparent background

.

+0

버튼에 투명한 배경과 동일한 문제가 있습니다. –