Reputation: 15
I have a Datagrid with say 5 Columns named as follows
RowID, Name, Age, Height, Image
What I want to do is when the mouse is over a cell in the Image Column, if there is an image there I want a pop up box to appear. I know I can just use a tool tip for the pop up but what's the best way of doing the check of is mouse over cell and does cell have an image present, if so then display popup.
EDIT:- Added code for DataGrid Column for Image Column
<DataGridTemplateColumn Header="Image">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Width="32" Height="32" HorizontalAlignment="Center" VerticalAlignment="Center"
Source="{Binding IMG, Converter={StaticResource ImageConvert}}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Upvotes: 0
Views: 1101
Reputation: 132588
You can use the IsMouseOver
property to determine if the mouse is over an object, and a MultiDataTrigger
to evaluate multiple conditions.
<Style TargetType="Image">
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="True" />
<Condition Binding="{Binding IMG, Converter={StaticResource IsImageNullConverter}}" Value="False" />
</MultiDataTrigger.Conditions>
<Setter Property="ToolTip">
<Setter.Value>
<!-- Your ToolTip here -->
</Setter.Value>
</Setter>
</MultiDataTrigger>
</Style.Triggers>
</Style>
Upvotes: 1
Reputation: 7421
There are a couple of ways. What I would recommend is to create a Template column type / style and implement this as a trigger when the mouse is within the cell.
Upvotes: 0