ShowToolTip Binding

Hi,

I cannot make it work. Looks like not supported.

XAML

ShowToolTip="{Binding ExtendedScanning, UpdateSourceTrigger=PropertyChanged}" />

C#

private bool _extendedScanning;
public bool ExtendedScanning

{
get { return _extendedScanning; }
set { _extendedScanning = value; OnPropertyChanged();}
}

Regards

Jakub



5 Replies

VS Vijayarasan Sivanandham Syncfusion Team March 2, 2022 02:19 PM UTC

Hi Jakub Olichwier,

We have prepared the simple sample and checked the reported issue “ShowToolTip not updated while bound with ViewModel property in SfDataGrid ” and unable to replicate the issue from our end. It is working fine as expected. Please find the tested sample from the below link,

Sample Link: https://www.syncfusion.com/downloads/support/forum/173316/ze/Sample-1797504646

Please have a look at this sample and let us know if we have missed any customization done in your application. Otherwise, try to reproduce the reported issue in this sample and revert to us with the modified sample and steps to replicate the issue. It will be more helpful for us to find the exact cause for the issue and to provide a prompt solution.

Regards,
Vijayarasan S



JO Jakub Olichwier March 2, 2022 08:17 PM UTC

Hi Vijayarasan,

Thank you for your answer. Your example works. ExtendedScanning property is also binded to checkbox to set its value. Setting the value by checkbox in code behind works, but it doesnt affect  ShowToolTip. ToolTip is only for one column

<syncfusion:GridTextColumn
HeaderText="File Name"
MappingName="Name"
AllowEditing="False"
Width="230"
ToolTipTemplate="{StaticResource TemplateToolTip}"
ShowToolTip="{Binding ExtendedScanning, UpdateSourceTrigger=PropertyChanged}" />

ToolTipTemplate doesn't influence - I've checked with and without it.

The error I got during debuging:

System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=ExtendedScanning; DataItem=null; target element is 'GridTextColumn' (HashCode=16490914); target property is 'ShowToolTip' (type 'Boolean')

The issue is I get null value, I don't know why. The checkbox works perfectly:

<CheckBox Name="extendedScanningCkb"
  Grid.Column="1" Grid.Row="6"
  Content="Extended File Info (turn on for extended file scanning)"
  IsChecked="{Binding ExtendedScanning, UpdateSourceTrigger=PropertyChanged}" />

Regards,

Jakub



MA Mohanram Anbukkarasu Syncfusion Team March 3, 2022 12:32 PM UTC

Hi Jakub,
We have modified the sample by adding a CheckBox and bind ExtendedScanning property to the IsChecked property of the CheckBox and the ShowToolTip property of the columns as you mentioned. But the reported issue doesn’t occur even if we change the CheckBox value in code behind. The binding for ShowToolTip property of the column works as expected. ToolTip is showing while hovering on the cells only when the CheckBox is in checked state.  


Please find the modified sample from the provided sample link and revert to us with details if still you are facing the same issue.  

Regards, 
Mohanram A. 



RV Ruud van der Giessen December 1, 2022 12:29 PM UTC

Hi,

I having the same issue that for datagrid columns where I use Binding I get the "Cannot find governing FrameworkElement" and "property not found on object of type GridTextColumn" binding errors. I download and ran your example but I see the the binding errors:




All seem to work fine, but I want to get rid of these binding failures. Can you please help?


Thanks,

Ruud van der Giessen



VS Vijayarasan Sivanandham Syncfusion Team December 2, 2022 06:46 PM UTC

Hi Ruud van der Giessen,

The reported problem occurs in SfDataGrid.Columns are not part of the visual tree and are therefore not connected to the data context of the SfDataGrid. We have checked in this case in the MSDN DataGrid. The same issue occurs.

Please refer to the below Stack Overflow link for more details.

Stack Overflow Link: https://stackoverflow.com/questions/7660967/wpf-error-cannot-find-governing-frameworkelement-for-target-element

However, you can overcome this problem by defining ViewModel (DataContext) inside Resources, and you can bind ViewModel to GridColumns by using StaticResource binding, as in the following code example.

<Window.Resources>

    <!--defining ViewModel (DataContext) inside Resources-->

    <local:ViewModel x:Key="viewModel" />

</Window.Resources>

 

<Grid DataContext="{StaticResource viewModel}">

    <Grid.ColumnDefinitions>

        <ColumnDefinition/>

        <ColumnDefinition Width="250"/>

    </Grid.ColumnDefinitions>

    <syncfusion:SfDataGrid x:Name="sfDataGrid"                               

                           ItemsSource="{Binding Orders}"

                           AutoGenerateColumns="False">

        <syncfusion:SfDataGrid.Columns>

            <!--ViewModel (DataContext) to GridColumns by using Source property-->

            <syncfusion:GridTextColumn MappingName="OrderID" HeaderText="Order ID" ShowToolTip="{Binding ExtendedScanning, UpdateSourceTrigger=PropertyChanged,Source={StaticResource viewModel}}" />

            <!--ViewModel (DataContext) to GridColumns by using Source property-->

            <syncfusion:GridTextColumn MappingName="CustomerID" HeaderText="Customer ID" ShowToolTip="{Binding ExtendedScanning, UpdateSourceTrigger=PropertyChanged,Source={StaticResource viewModel}}" />

            <syncfusion:GridTextColumn MappingName="CustomerName" HeaderText="Customer Name" />

            <syncfusion:GridTextColumn MappingName="Country" HeaderText="Country" />

            <syncfusion:GridTextColumn MappingName="UnitPrice" HeaderText="Unit Price" />

        </syncfusion:SfDataGrid.Columns>

    </syncfusion:SfDataGrid>

    <StackPanel Grid.Column="1">

        <!--ViewModel (DataContext) to CheckBox by using Source property-->

        <CheckBox Name="extendedScanningCkb" Content="Extended File Info (turn on for extended file scanning)" IsChecked="{Binding ExtendedScanning, UpdateSourceTrigger=PropertyChanged, Source={StaticResource viewModel}}" />

        <Button x:Name="btn" Content="Change CheckBox value Programatically" Width="200" Height="30" Click="OnEnableorDisableToolTipClicked"/>

    </StackPanel>

</Grid>


Find the modified sample in the attachment.

Regards,
Vijayarasan S

If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Attachment: Sample_ab806f2d.zip

Loader.
Up arrow icon