We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

System.InvalidOperationException and TooltipTemplateKey

Thread ID:

Created:

Updated:

Platform:

Replies:

104128 Jun 22,2012 11:15 PM UTC Jul 6,2012 04:23 AM UTC WPF 3
loading
Tags: GridControl
Wenbiao Liang
Asked On June 22, 2012 11:15 PM UTC

Hi guys,
We are using syncfusion:GridTreeControl grid in one of our UserControl. We need to show the tool tip for each column headers. And I have the following attributes set in the GridTreeControl in XAML.
syncfusion:GridTooltipService.ShowTooltips="True" 
syncfusion:GridTooltipService.TooltipDelay="0"

And in the GridQueryCellInfo() event handler, I have the following:
args.Style.ShowTooltip = true;

If I have also say:
args.Style.Tooltip = "Blah";    // which I think is wrong
The application will run fine, although no tooltip will show.

However, if I take out the line (args.Style.Tooltipe="Blah"), the program will crash whenever I hoover the cursor over to the header cell. The error I get is:

System.InvalidOperationException: The calling thread cannot access this object because a different thread owns it.
   at System.Windows.Threading.DispatcherObject.VerifyAccess()
   at System.Windows.Application.get_MainWindow()
   at Syncfusion.Windows.Controls.Grid.PopupDragWindow.Show()
   at Syncfusion.Windows.Controls.Grid.GridTooltipService.OnTick(Object sender, EventArgs e)
 
I believe it is because the application is trying to pop the tooltip, but somehow it was trying to access an object owned by another thread.

If I create a DataTemplate in the <Grid.Resources/> in my UserControl's XAML code, and set:
args.Style.ToolTipTemplateKey = "xxxyyyzzz"; // xxxyyyzzz is the x:Key of the DataTemplate in the XAML, then I will get the crash with the same error.

Could you please help?! Our version is: Syncfusion.Core, Version=8.304.0.22

Thanks!
Wenbiao

Rajasekar G [Syncfusion]
Replied On June 26, 2012 07:42 PM UTC

Hi Wenbiao,

 

Thanks for the patience.

 

We have analyzed your and you can achieve your requirement by using the following code snippet.

 

Code Snippet[XAML]:

 

<Window.Resources>
    <DataTemplate x:Key="source" DataType="{x:Type ToolTip}">
        <Border Background="Red" BorderThickness="3" BorderBrush="Black" >
        <TextBlock Text="Tool Tip" Width="70" FontSize="12" FontWeight="Bold"></TextBlock>
        </Border>
    </DataTemplate>
</Window.Resources>

 

 

Code Snippet[C#]:

 

this.GridTree.ModelLoaded += new EventHandler(GridTree_ModelLoaded);

 

void GridTree_ModelLoaded(object sender, EventArgs e)

{

    GridTooltipService.SetShowTooltips(this.GridTree.InternalGrid, true);

    GridTooltipService.SetTooltipDelay(this.GridTree.InternalGrid, 0);

    this.GridTree.InternalGrid.QueryCellInfo += new Syncfusion.Windows.Controls.Grid.GridQueryCellInfoEventHandler(InternalGrid_QueryCellInfo);

}

 

void InternalGrid_QueryCellInfo(object sender, Syncfusion.Windows.Controls.Grid.GridQueryCellInfoEventArgs e)

{

    if (e.Cell.RowIndex == 0)

    {

        e.Style.ShowTooltip = true;

        e.Style.TooltipTemplateKey = "source";

    }

}

 

We have prepared a sample based on this and it can be download from the following location.

 

Sample Location: GridTreeControl.zip

 

Snap Shot:

 


 

Please let us know if you have any questions.

 

Thanks,

Raja sekar. G

Wenbiao Liang
Replied On June 29, 2012 06:58 PM UTC

Raja,
Thanks for the update.

I followed your instructions to the letter, but I still get the same errors when I hover the mouse over the cells:

System.InvalidOperationException: The calling thread cannot access this object because a different thread owns it.
   at System.Windows.Threading.DispatcherObject.VerifyAccess()
   at System.Windows.Application.get_MainWindow()
   at Syncfusion.Windows.Controls.Grid.PopupDragWindow.Show()
   at Syncfusion.Windows.Controls.Grid.GridTooltipService.OnTick(Object sender, EventArgs e)
   at System.Windows.Threading.DispatcherTimer.FireTick(Object unused)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)

If I do this:
args.Style.ToolTip = "Blah Blah";
then I don't get the error when I mouse hover the cell.

Any help will be greatly appreciated!

Thanks!
Wenbiao

Rajasekar G [Syncfusion]
Replied On July 6, 2012 04:23 AM UTC

Hi Wenbiao,

Sorry for the inconvenience caused.

We have tested the reported issue with our sample and we are unable to reproduce the issue. Could you please check the sample in the following location? If the problem still exist, please revert us by modifying the sample based on your application along with replication procedure. This would be helpful for us to serve you.

Sample location: GridTreeControl.zip
Video location :
Video.zip  

 Please let us know if you have any questions.

Thanks,

Raja sekar.G

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;