Link to home
Start Free TrialLog in
Avatar of Steven_Prescott
Steven_Prescott

asked on

Dynamic Tooltip WPF

Firstly; I am very very new to WPF - so please excuse me if this sounds ridiculous.
I need to have dynamic tool tips in my application. The data in the tooltips can change so I can't just hard code them; the contents of the tooltips will probably be stored in a database (or a wiki)
Is there a way in WPF that I can perhaps bind my tooltip to an underlying business class that can go away and return the correct tool tip?

Any help would be very much appreciated
Thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of unmeshdave
unmeshdave
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Steven_Prescott
Steven_Prescott

ASKER

There are a number of errors coming up when I attempt the above example... I am not sure if this is due to a schema that I am using? or just how I am attempting to bind the tooltip..
I have attached the xaml code and the basic outline of the underlying class that I want to attach to.
I want the tooltip for the name to show the current name and likewise for the age

Any help on this would be very much appreciated
Thanks in advance
This is the xaml file...
<Window x:Class="WpfApplication1.Window2"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window2" Height="110" Width="270">
 
    <Grid ShowGridLines="True">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="200" />
        </Grid.ColumnDefinitions>
        <Label Grid.Row="0" Grid.Column="0" Content="Name:" />
        <Label Grid.Row="1" Grid.Column="0" Content="Age:" />
 
        <TextBox Grid.Row="0" Grid.Column="1" Margin="3" Name="txtName" />
        <TextBox Grid.Row="1" Grid.Column="1" Margin="3" Name="txtAge" />
        <Button Grid.Row="2" Grid.Column="1" Name="incrementAgeButton" Click="incrementAge_Click">Increment Age</Button>
    </Grid>
</Window>
 
and this is the shape of the class
public class Person
{
   public string Name
   public int Age
}

Open in new window

If you want to bind Name and age to the relevant textbox tooltip, you need to declare them as properties. also please show how you put tooltip code, and what errors you are getting.
I had not put a datacontext in the "parent" grid