-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2829 from telerik/new-kb-kb-docking-invalidoperat…
…ionexception-input-bindings-11ad6da4d2b343fba04661649330ed9b Added new kb article kb-docking-invalidoperationexception-input-bindings
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
knowledge-base/kb-docking-invalidoperationexception-input-bindings.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
title: Calling thread cannot access this object when opening RadDocking on another UI thread | ||
type: how-to | ||
page_title: InvalidOperationException is thrown when showing Docking on separate thread. | ||
description: "The calling thread cannot access this object because a different thread owns it, when RadDocking is started on a new UI thread." | ||
slug: kb-docking-invalidoperationexception-input-bindings | ||
tags: raddocking, multiple-threads, exception, thread | ||
res_type: kb | ||
--- | ||
|
||
# Environment | ||
| Product | RadDocking for WPF | | ||
| ------- | ----------------- | | ||
| Version | 2019.2.618 | | ||
|
||
## Description | ||
|
||
`InvalidOperationException` is thrown when `RadDocking` is hosted in a window that can be opened on separate UI threads. | ||
|
||
The exception message is: *"The calling thread cannot access this object because a different thread owns it."* | ||
|
||
## Solution | ||
|
||
This happens because of a `MouseBinding` defined in the `InputBindings` collection of one of the `RadDocking` visuals (the `PaneHeader` element). | ||
|
||
To avoid the issue, you can add a new `Style` for the `PaneHeader` element in the Resources of the window that opens on the new UI thread. | ||
|
||
#### __[XAML]__ | ||
{{region kb-docking-invalidoperationexception-input-bindings-0}} | ||
<UserControl.Resources> | ||
<!--If you use NoXaml dlls please add BasedOn="{StaticResource PaneHeaderStyle}" to the Style object. For example: --> | ||
<!--<Style TargetType="telerik:PaneHeader" BasedOn="{StaticResource PaneHeaderStyle}" >--> | ||
<Style TargetType="telerik:PaneHeader"> | ||
<Setter Property="telerik:InputBindingsManager.InputBindings"> | ||
<Setter.Value> | ||
<InputBindingCollection> | ||
<MouseBinding Command="telerikDocking:RadDockingCommands.PaneHeaderMenuOpen"> | ||
<MouseBinding.Gesture> | ||
<MouseGesture MouseAction="RightClick" /> | ||
</MouseBinding.Gesture> | ||
</MouseBinding> | ||
</InputBindingCollection> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
</UserControl.Resources> | ||
{{endregion}} | ||
|
||
In some cases, you may need to merge this `Style` in the `Resources` of the opened `ToolWindow`. To do this, you can use the `ToolWindowCreated` event of `RadDocking`, where you can access the `Resources` of the window in code-behind. | ||
|