2016-09-02 4 views
-1

私はカスタムControl(ButtonAnalysisControl)のスタイルを作成しました。 ToolTip以外はすべて動作しています。 MenuItemの上にマウスを移動すると、ToolTipは表示されません。私はMenuItemsSnoopと検査し、ToolTipの値が正しく設定されています。ツールヒントを動作させるにはどうすればよいですか?ボーナスに関する質問:ContextMenuBorderを削除するにはどうすればよいですか?MenuItemにツールヒントが表示されない

たContextMenu:

ContextMenu

Generic.xamlスタイル

<Style TargetType="anal:ButtonAnalysisControl"> 

    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="anal:ButtonAnalysisControl"> 

       <ControlTemplate.Triggers> 
        <EventTrigger RoutedEvent="Click"> 
         <BeginStoryboard> 
          <Storyboard> 
           <BooleanAnimationUsingKeyFrames Storyboard.TargetName="ContextMenu" Storyboard.TargetProperty="(ContextMenu.IsOpen)"> 
            <DiscreteBooleanKeyFrame KeyTime="00:00:00" Value="True"/> 
           </BooleanAnimationUsingKeyFrames> 
          </Storyboard> 
         </BeginStoryboard> 
        </EventTrigger> 
       </ControlTemplate.Triggers> 

       <ControlTemplate.Resources> 
        <anal:CustomMultiValueConvertor x:Key="CustomMultiValueConvertor"/> 
        <anal:IntToPercentageBrushConvertor x:Key="IntToPercentageBrushConvertor"/> 
       </ControlTemplate.Resources> 

       <Grid> 
        <Grid.RowDefinitions> 
         <RowDefinition Height="Auto" /> 
         <RowDefinition Height="*"/> 
        </Grid.RowDefinitions> 

        <Grid.ColumnDefinitions> 
         <ColumnDefinition Width="*" /> 
        </Grid.ColumnDefinitions> 

        <Grid.ContextMenu> 
         <ContextMenu Name="ContextMenu" IsOpen="False" Placement="Top" PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"> 
          <ContextMenu.ItemsSource> 
           <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ChildCommands"/> 
          </ContextMenu.ItemsSource> 
          <ContextMenu.ItemContainerStyle> 
           <Style TargetType="{x:Type MenuItem}"> 
            <Setter Property="MenuItem.Header"> 
             <Setter.Value> 
              <MultiBinding Converter="{StaticResource CustomMultiValueConvertor}"> 
               <Binding Path="Percentage" /> 
               <Binding Path="ViewCommand.Command.Text" /> 
              </MultiBinding> 
             </Setter.Value> 
            </Setter> 
            <Setter Property="MenuItem.IsEnabled" Value="False"/> 
            <Setter Property="MenuItem.Background" Value="{Binding Percentage, Converter={StaticResource IntToPercentageBrushConvertor}}"/> 
            <Setter Property="MenuItem.Padding" Value="0"/> 
            <Setter Property="MenuItem.BorderThickness" Value="0"/>  
            <Setter Property="MenuItem.ToolTip" Value="123"/>           
           </Style> 
          </ContextMenu.ItemContainerStyle> 
          <ContextMenu.ItemsPanel> 
           <ItemsPanelTemplate> 
            <VirtualizingStackPanel Orientation="Vertical"/> 
           </ItemsPanelTemplate> 
          </ContextMenu.ItemsPanel> 
         </ContextMenu> 
        </Grid.ContextMenu> 

        <TextBlock TextAlignment="Center" 
           VerticalAlignment="Stretch" 
           Foreground="{StaticResource CommandBarForeground}" 
           Background="{StaticResource MainForegroundBrush}" 
           FontFamily="{StaticResource FontFamily}" 
           FontSize="10" 
           Grid.Column="0" 
           Grid.Row="0"> 
         <TextBlock.Text> 
          <Binding Path="Text" StringFormat="{}{0}%" RelativeSource="{RelativeSource TemplatedParent}" /> 
         </TextBlock.Text>        
        </TextBlock> 
        <Rectangle Grid.Column="0" 
           Grid.Row="1"> 
         <Rectangle.Fill> 
          <Binding Path="BackgroundBrush" RelativeSource="{RelativeSource TemplatedParent}" /> 
         </Rectangle.Fill> 
        </Rectangle>       
       </Grid> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 

</Style> 
+0

Downvoter:説明してください? – Sybren

+0

通常のコンテキストメニューにツールチップが表示されているかどうかチェックしましたか?他人が簡単に使うことができる形で質問を投稿しようとする。 – AnjumSKhan

答えて

1

は、私は答えを見つけた:のMenuItemが無効になっているので、ツールヒントが表示されませんでした。それを修正私のMenuItemのスタイルに次の行を追加し

<Setter Property="ToolTipService.ShowOnDisabled" Value="True" /> 
+0

heres my upvote – AnjumSKhan

関連する問題