Hi,
I have a style i'm using for tooltips- it includes Image and some TextBlock in it (as ControlTemplate).
i would like to bind Image Source to one of my properties in the code behind- currently it's hard coded to "Images/Crab.png".
(already done successfully- bind TextBlock text to Content property)
any idea?
here's the code i wrote:
<Style x:Key="ToolTipInventoryTemplate" 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="Transparent" Offset="0"/>
<GradientStop Color="Transparent" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80" />
<ColumnDefinition Width="80" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="80"/>
<RowDefinition Height="80"/>
</Grid.RowDefinitions>
<Image Source="Images/Crab.png" Grid.RowSpan="2" Grid.ColumnSpan="2" Margin="3" Stretch="Fill"/>
<TextBlock FontFamily="Tahoma" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Grid.RowSpan="2" FontSize="13"
Text="{TemplateBinding Content}"
Foreground="Black" TextWrapping="Wrap" FontWeight="ExtraBold" Margin="35"/>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>