2013-07-03 31 views
5

Basit bir düğme için bir araç ipucu oluşturmaya çalışıyorum. Ancak, fare düğmenin üzerine getirildiğinde, araç ucu bunun altında görünmez.Araç İpucu Yerleşimi - WPF

bu bakın: enter image description here

Bu xaml aşağıdaki gibidir:

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Height="300" Width="300" xmlns:sys="clr-namespace:System;assembly=mscorlib"> 

    <Page.Resources> 

     <Style x:Key="ToolTipStyle" TargetType="{x:Type ToolTip}"> 
      <Setter Property="OverridesDefaultStyle" Value="true" /> 
      <Setter Property="Template"> 
       <Setter.Value> 
        <ControlTemplate TargetType="ToolTip"> 
         <Grid x:Name="PopupGrid"> 
          <Grid x:Name="ShadowBackground" Height="65" Width="260"> 
           <Grid.Effect> 
            <DropShadowEffect BlurRadius="7" ShadowDepth="1" Opacity="0.5" /> 
           </Grid.Effect> 
           <Path Margin="0 0 50 0" Width="20" Height="10" HorizontalAlignment="Right" VerticalAlignment="Top" Data="M0,10 L10,0 20,10Z" Stroke="Gray" Fill="#EFEFF0" Stretch="None" /> 
           <Border BorderThickness="1 0 1 1" CornerRadius="3" Margin="10 9 10 10" BorderBrush="Gray" Background="#EFEFF0"> 
            <ContentPresenter/> 
           </Border> 
           <Border BorderThickness="0 1 0 0" CornerRadius="0 0 3 0" Margin="0 9 10 0" HorizontalAlignment="Right" VerticalAlignment="Top" Width="41" Height="10" BorderBrush="Gray" /> 
           <Border BorderThickness="0 1 0 0" CornerRadius="3 0 0 0" Margin="10 9 69 0" VerticalAlignment="Top" Height="10" BorderBrush="Gray" /> 

          </Grid>      
         </Grid> 
        </ControlTemplate> 
       </Setter.Value> 
      </Setter> 
     </Style> 

     <Style x:Key="ToolTipHeaderStyle" TargetType="{x:Type Label}"> 
      <Setter Property="FontFamily" Value="Calibri"/> 
      <Setter Property="FontWeight" Value="Bold"/> 
      <Setter Property="FontSize" Value="14"/> 
     </Style> 

     <Style x:Key="ToolTipTextStyle" TargetType="{x:Type Label}"> 
      <Setter Property="FontFamily" Value="Calibri"/> 
      <Setter Property="FontSize" Value="12"/> 
     </Style> 

    </Page.Resources> 

    <Grid x:Name="PopupGrid" Background="Red"> 
     <Button Width="100" Height="30" Content="Click Me!"> 
      <Button.ToolTip> 
       <ToolTip Style="{StaticResource ToolTipStyle}"> 
        <StackPanel Orientation="Vertical"> 
         <Label Content="Newly Rejected" Style="{StaticResource ToolTipHeaderStyle}"></Label> 
         <Label Content="Please perform requested edits and resubmit" Style="{StaticResource ToolTipTextStyle}"></Label> 
        </StackPanel> 
       </ToolTip> 
      </Button.ToolTip> 
     </Button> 
    </Grid> 

</Page> 

Ben bu davranışı neden olan emin değilim. Yerleşimi düzeltmeye yardımcı olabilir misiniz?

araç ipucu üçgen ipucu böyle left.Something yönünde harekete geçmesi anlamına geleceğini sağ fare imleci altında yerler olmalıdır:

o nasıl görüneceğini söylemeyi unutmuşum enter image description here

Teşekkürler, -Mike

+0

: http://stackoverflow.com/questions/14275755/wpf-button-with-image-trigger-mouseover-to-change geri arama arkasında kod ofset bir akrabası hesaplamak için -image IsMouseOver özelliği durumunuz için ayarlanmamış. – Naresh

+0

Farenin nasıl çözüleceğinden emin değilim. – Mike

+0

iyi, hiç araç ipucu kullanmadım, ama anladığım şey, düğmeyi farenin üzerine getirdiğinizde, bir kutu göstermesi gerektiğidir. Bunun için mouseover olayını tetiklemeniz gerekmez mi? Emin değilim. umarım bazı uzmanlar açıklığa kavuşur. – Naresh

cevap

3

Yerleşim özellikleriyle oynamış mısınız?

Sen ToolTipStyle Bu ekleyebilirsiniz:

Sen deneyebilirsiniz:

<Setter Property="ToolTipService.HorizontalOffset" Value="-200" /> 
+0

Bu işe yaramıyor, hedef de. – Mike

+0

Cevabımı, sorununuzu çözmenin başka bir olası yolu ile düzenledim. – TrueEddie

+0

Ancak araç ipucu bir veri türü içinde belirtildiğinde işe yaramıyor..See: http://stackoverflow.com/questions/17451723/placement-target-binding-inside-a-datatemplate-tooltip – Mike

2

da DÜZENLEME ToolTipService.PlacementRectangle ve ToolTipService.PlacementTarget

var
<Setter Property="ToolTipService.Placement" Value="Left" /> 

CustomPopupPlacementCallback'i kullanın. Benim durumumda, bir metin kutusunun sağ tarafında görüntülenecek ipucuna ihtiyacım vardı, Placement.Right dizüstü bilgisayarımda iyi çalıştı, ancak dokunmatik ekranımda solda görüntüleniyordu, bunu düzeltmenin en kolay yolu kullanmaktır Bunu görebilirsiniz

... 
tip.PlacementTarget = this; 
tip.Placement = PlacementMode.Custom; 
tip.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(PositionTooltip); 
... 

    private CustomPopupPlacement[] PositionTooltip(Size popupSize, Size targetSize, Point offset) 
    { 
     double offsetY = targetSize.Height/2 + popupSize.Height; 
     double offsetX = targetSize.Width; 

     return new CustomPopupPlacement[] { new CustomPopupPlacement(new Point(offsetX, offsetY), PopupPrimaryAxis.None) }; 
    }