Click here to Skip to main content
15,886,678 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two buttons in Main.Xaml. I declare ToolTip for each of them. They have a very small gap which is barely visible with open eyes but still they have gap which you you can see by their Margin.

<button
 
="" x:name="button1" width="71" horizontalalignment="Left" margin="165,14,0,0" height="24" verticalalignment="Top" uselayoutrounding="True" renderoptions.cleartypehint="Enabled" renderoptions.bitmapscalingmode="NearestNeighbor" snapstodevicepixels="True">
             <button.content>
                 <textblock fontsize="10" fontfamily="Segoe UI" uselayoutrounding="True" textoptions.textformattingmode="Display" margin="0,-2,0,0">
                     Settings
                 
                 
               <button.tooltip>
 <tooltip uselayoutrounding="True" renderoptions.cleartypehint="Enabled" renderoptions.bitmapscalingmode="NearestNeighbor" snapstodevicepixels="True" textoptions.textformattingmode="Display" 
="">
                     <stackpanel>
                         <textblock fontfamily="Segoe UI" fontsize="12" textoptions.textformattingmode="Display"> 
                            Settings
                         
                     
                   
             
         
    
    
            `enter code here`<button
 
="" x:name="button2" width="71" horizontalalignment="Left" margin="237,14,0,0" height="24" verticalalignment="Top" uselayoutrounding="True" renderoptions.cleartypehint="Enabled" renderoptions.bitmapscalingmode="NearestNeighbor" snapstodevicepixels="True">
             <button.content>
                 <textblock fontsize="10" fontfamily="Segoe UI" uselayoutrounding="True" textoptions.textformattingmode="Display" margin="0,-2,0,0">
                     Settings
                 
                 
               <button.tooltip>
 <tooltip uselayoutrounding="True" renderoptions.cleartypehint="Enabled" renderoptions.bitmapscalingmode="NearestNeighbor" snapstodevicepixels="True" textoptions.textformattingmode="Display" 
="">
                     <stackpanel>
                         <textblock fontfamily="Segoe UI" fontsize="12" textoptions.textformattingmode="Display"> 
                            Settings








I have created two control template one is for button which is consider as "RoundCorner" and declare as StaticResource of buttons in Main.XAMl. And another is for ToolTip.

Here is the Code for RoundCorner Controltemplate(Button) --

 <Setter Property="HorizontalContentAlignment" Value="Center"/>
 <Setter Property="VerticalContentAlignment" Value="Center"/>
 <Setter Property="Padding" Value="1"/>
 <Setter Property="Foreground" Value="#bababa" />
<Setter Property="Template">
     <Setter.Value>
         <ControlTemplate TargetType="{x:Type Button}">
             <Grid x:Name="grid" >
                 <Border x:Name="border" CornerRadius="1"  BorderThickness="0"  >
                     <Border.Background>
                         <RadialGradientBrush GradientOrigin="0.496,1.052">
                             <RadialGradientBrush.RelativeTransform>
                                 <TransformGroup>
                                     <ScaleTransform CenterX="0.5" CenterY="0.5"
                                         ScaleX="1.5" ScaleY="1.5"/>
                                     <TranslateTransform X="0.02" Y="0.3"/>
                                 </transformgroup>
                             </radialgradientbrush.RelativeTransform>
                             <GradientStop Offset="1" Color="#282828"/>
                             <GradientStop Offset="0.3" Color="#282828"/>
                         </radialgradientbrush>
                     </border.Background>
                     <ContentPresenter
                         HorizontalAlignment="Center"
                         VerticalAlignment="Center"
                           >
                     </contentpresenter>
                 </border>

             </grid>

             <ControlTemplate.Triggers>

                 <Trigger Property="IsMouseOver" Value="True">
                     <Setter Property="Background" TargetName="border" Value="#202020"/>
                     <Setter Property="Foreground" Value="WhiteSmoke" />

                 </trigger>

               <Trigger Property="IsPressed" Value="True">
                     <Setter Property="Background" TargetName="border">
                         <Setter.Value>
                             <RadialGradientBrush GradientOrigin="0.496,1.052">
                                 <RadialGradientBrush.RelativeTransform>
                                     <TransformGroup>
                                         <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="1.5" ScaleY="1.5"/>
                                         <TranslateTransform X="0.02" Y="0.3"/>
                                     </transformgroup>
                                 </radialgradientbrush.RelativeTransform>
                                 <GradientStop Color="#161616" Offset="1"/>
                                 <GradientStop Color="#161616" Offset="0.3"/>
                             </radialgradientbrush>
                         </setter.Value>
                     </setter>
                 </trigger>

           </controltemplate.Triggers>

         </controltemplate>
     </setter.Value>
 </setter>





Here is the Control template code for Tooltip--


      <Setter Property="OverridesDefaultStyle"
Value="True" />
      <Setter Property="HasDropShadow"
Value="True" />
      <Setter Property="ToolTipService.Placement"
Value="MousePoint" />
      <Setter Property="ToolTipService.VerticalOffset"
Value="5"   />
      <Setter Property="ToolTipService.HorizontalOffset"
Value="-10" />
      <Setter Property="Foreground"
Value="#606060"/>
      <Setter Property="ToolTipService.InitialShowDelay"
Value="1000" />
      <Setter Property="ToolTipService.BetweenShowDelay"
Value="0" />
      <Setter Property="ToolTipService.ShowDuration"
Value="6000" />

      <Setter Property="Template">
          <Setter.Value>
              <ControlTemplate TargetType="{x:Type ToolTip}">

                  <Grid x:Name="grid"  Margin="10"  >

                      <Border x:Name="Bordermini"  HorizontalAlignment="Right"
      BorderThickness="0.5"

      Width="{TemplateBinding Width}"
      Height="15">

                          <Border.Background>
                              <LinearGradientBrush StartPoint="0,0"
                       EndPoint="0,1">
                                  <LinearGradientBrush.GradientStops>
                                      <GradientStopCollection>
                                          <GradientStop Color="White"
                      Offset="0.0" />
                                          <GradientStop Color="White"
                      Offset="1.0" />
                                      </gradientstopcollection>
                                  </lineargradientbrush.GradientStops>
                              </lineargradientbrush>

                          </border.Background>

                          <Border.BorderBrush>
                              <SolidColorBrush Color="Gainsboro" />
                          </border.BorderBrush>

                          <Border.Effect>

                              <DropShadowEffect   Opacity="0.8"  BlurRadius="5"  Direction="-82" ShadowDepth="3.8" Color="#282828"      >
                          </dropshadoweffect>

                          </border.Effect>

                <ContentPresenter Margin="1.5,0"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top" />
                      </border>

       <Border x:Name="Border"  HorizontalAlignment="Right"
      BorderThickness="0.5"

      Width="{TemplateBinding Width}"
      Height="19">
                          <Border.Background>
                              <LinearGradientBrush StartPoint="0,0"
                       EndPoint="0,1">
                                  <LinearGradientBrush.GradientStops>
                                      <GradientStopCollection>
                                          <GradientStop Color="#ffffff"
                      Offset="0.0" />
                                          <GradientStop Color="#ffffff"
                      Offset="1.0" />
                                      </gradientstopcollection>
                                  </lineargradientbrush.GradientStops>
                              </lineargradientbrush>

                          </border.Background>

                          <Border.BorderBrush>
                              <SolidColorBrush Color="Gray" />
                          </border.BorderBrush>

                          <ContentPresenter Margin="4,0"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Top" />
                      </border>

                  </grid>

                  <ControlTemplate.Triggers>
                      <Trigger Property="HasDropShadow" Value="True" >

                          <Setter TargetName="Border"
          Property="CornerRadius"
          Value="0" />
                          <Setter TargetName="Border"
          Property="SnapsToDevicePixels"
          Value="true" />
                  </trigger>

                  </controltemplate.Triggers>
              </controltemplate>
           </setter.Value>
      </setter>




So, How I re trigger the initial delay as soon as I quickly move the mouse cursor from one button to another? Is there any need to use the "Datatrigger" or "DataBinding" to overcome this issue?

What I have tried:

I tried using various data binding with Tooltip IsOpen property but none of them are working.
Posted
Updated 27-Oct-21 0:46am
v3
Comments
[no name] 27-Oct-21 11:24am    
Go back to a plain button and a "string" tool tip; i.e. what's important. Then start adding all the lipstick back in until it stops behaving: there's your answer.
Member 15061773 27-Oct-21 11:32am    
Thank you sir. My problem actually solved in Stack overflow but the problem is using an third party NuGet packages which is unfortunately not available now.

Can you please tell me that How I can solve this using any trigger? or Data Binding

Here is the Stack overflow link :https://stackoverflow.com/questions/63510347/tooltip-appears-instantly-in-wpf-does-not-trigger-initial-delay
[no name] 27-Oct-21 11:37am    
My original suggestion stands: a tool tip is a (short) "tip"; not a help screen or dialog.
Member 15061773 27-Oct-21 11:42am    
I understand that and I also know that sir. I don't use any long sentence as button content in the ToolTip content. Due to design purpose I have to do it in this way. By the way it's not my project. It's our office project so, the client wants that's way. Please help me. And kindly read the stack overflow post which I given as a link.

If you know how to achieve by using a trigger then please help me. Don't give your personal suggestion. If you know that then please tell me otherwise just ignore.
[no name] 28-Oct-21 12:23pm    
My suggestion is also based on your skill level; as reflected in your code: the duplication, lack of awareness for scaling and position, pointless property settings, etc. Not "personal", my "professional" opinion. Standards are created for a purpose: the inexperienced. You've turned what should be a "one-liner" (the "tip") into a journey; and that wastes your "client's" money.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900