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
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
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
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.