1

In order to not have to many columns in my grid, I would like to show some not so important ones in a Tooltip.

This Tooltip should be displayed as soon as the user is having his mouse over any row/cell of my data grid.

The datagrid is bound directly to my collection of objects.

I've done this so far but can't get the values of my bindings populated in the tool tip:

 <dxg:GridControl ItemsSource="{Binding Cars[Pending]}" AutoPopulateColumns="True">
    <dxg:GridControl.View>
        <dxg:TableView Style="{StaticResource DxTableViewStyle}" FocusedRow="{Binding Path=PendingCarSelected,Mode=TwoWay}">
            <dxg:TableView.CellStyle>
                <Style TargetType="dxg:CellContentPresenter">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Mode=Self}}" Value="True">
                            <Setter Property="ToolTip">
                                <Setter.Value>
                                    <StackPanel>
                                        <WrapPanel>
                                            <TextBlock Text="Car Brand:"/>
                                            <TextBlock Text="{Binding Brand}"/>
                                        </WrapPanel>
                                        <WrapPanel>
                                            <TextBlock Text="Car Type:"/>
                                            <TextBlock Text="{Binding Type}"/>
                                        </WrapPanel>
                                    </StackPanel>
                                </Setter.Value>
                            </Setter>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </dxg:TableView.CellStyle>
        </dxg:TableView>
    </dxg:GridControl.View>
    <dxg:GridControl.Columns>
        <dxg:GridColumn Header="Engine" FieldName="Engine" ReadOnly="False" />
        <dxg:GridColumn Header="Id" FieldName="Id" ReadOnly="True" />

Would you have an idea on how to solve this? Ideally, if no value avaialble, would also like to replace it by an "-"

thank you!

goul
  • 813
  • 1
  • 13
  • 32
  • Is the tool tip visible at all? For the default value you want to use the FallbackValue of the Binding object to provide something, that is shown, when no valid binding is available – Samuel Jul 09 '13 at 07:05
  • The tooltip is visible. It actually shows the "Car Brand:" and "Car Type:" texts, however the mappings don't work --> on that matter, the grid columns mappings are actually working. Thanks for the FallbackValue, that's working – goul Jul 09 '13 at 07:41
  • This is not a solution for your issue, but instead of a tool tip you could use the RowDetails Template of DataGrid to display the additional information. I cannot help you with the Binding issue here as I am a beginner there :/ – Samuel Jul 09 '13 at 08:03
  • Thanks but I actually want to add a ToolTip instead of adding some extra info in the row. Thanks again for your help! – goul Jul 09 '13 at 08:20
  • Try wrapping your `StackPanel` in an actual `ToolTip` element and then try setting it's DataContext in xaml as `DataContext="{Binding RelativeSource={RelativeSource Self}, Path=PlacementTarget}"`. This should get the DataContext to flow through to the `ToolTip` children. This just looks like an issue of the DataContext not being set properly for the ToolTip child controls. [Binding Example](http://stackoverflow.com/a/16925300/1834662) – Viv Jul 09 '13 at 08:53
  • Thanks. Actually I was sort of able to make it working by updating the path to something like this: . However the behavior is really random and wondering if this shouldn't be off the Styles. Is that what you are meaning by wrapping the StackPanel in an actual ToolTip? I don't find yet how to do so as there is ToolTips only avaialble per column and not rows – goul Jul 09 '13 at 10:06

0 Answers0