Click here to Skip to main content
15,885,868 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i am using WPF

my question is

i wamt pop/Show tooltip when particulaer text is entered in combo box

VB
   If cmbDatabase.Text.ToUpper = "TRAINING" Then
 Dim tool As New ToolTip()
  tool.Content = "Warning : You are about to log into a training database" &  
     

  cmbDatabase.tooltip = tool

  tool.IsOpen = True

end if



Above code is Showing tooltip but its basic no balloons etc


i have another code which is designed in xaml

but the issue is i cant show it When particuler text is Entered





XML
<Window.Resources>
      <Style x:Key="{x:Type ToolTip}" TargetType="ToolTip">
          <Setter Property="OverridesDefaultStyle" Value="true"/>
          <Setter Property="HasDropShadow" Value="True"/>
          <Setter Property="Template">
              <Setter.Value>
                  <ControlTemplate TargetType="ToolTip">
                      <Border CornerRadius="7" HorizontalAlignment="Center" VerticalAlignment="Top" Padding="5" BorderThickness="3,3,3,3" >
                          <Border.Background>
                              <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                  <GradientStop Color="#CF181818" Offset="0"/>
                                  <GradientStop Color="#BE1C1C1C" Offset="1"/>
                              </LinearGradientBrush>
                          </Border.Background>
                          <!--<Border.BorderBrush>
                              <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                  <GradientStop Color="#80FFFFFF" Offset="0"/>
                                  <GradientStop Color="#7FFFFFFF" Offset="1"/>
                                  <GradientStop Color="#FFFFF18D" Offset="0.344"/>
                                  <GradientStop Color="#FFFFF4AB" Offset="0.647"/>
                              </LinearGradientBrush>
                          </Border.BorderBrush>-->
                          <Grid>
                              <Grid.ColumnDefinitions>
                                  <ColumnDefinition Width="0.1*" />
                                  <ColumnDefinition Width="0.9*" />
                              </Grid.ColumnDefinitions>
                              <Grid.RowDefinitions>
                                  <RowDefinition Height="Auto"/>
                                  <RowDefinition Height="Auto"/>
                              </Grid.RowDefinitions>
                              <!--<Image Source="pack://application:,,,/resources/info_icon.jpg" Grid.Row="0" Grid.RowSpan="2" Grid.Column="0" Margin="3" />-->
                              <TextBlock FontFamily="Tahoma" Grid.Row="0" Grid.Column="1" FontSize="13" Text="{TemplateBinding Content}" Foreground="#5095D6" />
                              <TextBlock FontFamily="Tahoma" Grid.Row="1" Grid.Column="1" FontSize="11" Text="To expediate your process please click here" Foreground="#FFFFFFFF" />
                          </Grid>
                      </Border>
                  </ControlTemplate>
              </Setter.Value>
          </Setter>
      </Style>
  </Window.Resources>



above code shows tooltip on combobox mousehover



Please Help!!
Posted
Updated 7-Aug-14 23:34pm
v3

1 solution

Tooltips are meant to be shown only when a user hovers over the control with the mouse. You are misusing the tooltip control.

Create a value converter that takes a string and returns a Visibility. Add a label or something close to your text box that presents the warning. Bind the visibility property to the textbox's text property (using an element binding) and add the value converter to the binding. Then, when the text in the box matches what your converter is looking for, the label will become visible.
 
Share this answer
 

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