Invalid toolwindow name

Docking/MDI for WPF Forum

Posted 14 years ago by Roger Rong
Version: 9.2.0515
Avatar
I created a toolwindow in the code using following code:

ToolWindow tw = new ToolWindow(dockSite, '0d9e8171-a581-4b7e-9ca5-31f210849abc', title, windowImageSource, windowContent);
The above code threw an exception:

'0d9e8171-a581-4b7e-9ca5-31f210849abc' is not a valid value for property 'Name'.

It worked when I changed the name to something like "toolwindow1". But the problem is that we would like to use a GUID as the window name to avoid windows having same names. Any suggestion on this problem?

Comments (2)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Roger,

The Name property is inherited from FrameworkElement and must conform to standard identifier syntax. So to get GUIDs working, you could append an underscore at the front and convert all - chars to underscores too.


Actipro Software Support

Posted 14 years ago by Roger Rong
Avatar
Thanks. Your suggestion works.

For other people who encounter the same problem, here is the MSDN description regarding the FrameworkElement.Name Property :

The string values used for Name have some restrictions, as imposed by the underlying x:Name Attribute defined by the XAML specification. Most notably, a Name must start with a letter or the underscore character (_), and must contain only letters, digits, or underscores. For more information, see WPF Namescopes.

[Modified at 04/08/2010 05:24 PM]
The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.