XamlReader has problem with WindowsFormsHost

H

Haiping

I use XamlWriter to write a UserControl to xaml string. The UserControl has
the following namespace:
xmlns:wfi="clr-namespaceystem.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
But the xaml string does not have the WindowsFormsIntegration namespace. It
also has <av:WindowsFormsHost>. I added WindowsFormsIntegration namespace in
the xaml string and change <av:WindowsFormsHost> to <wfi:WindowsFormsHost>.

When XamlReader parse a xaml string it throws the following exception:
"The tag 'WindowsFormsHost' does not exist in XML namespace
'clr-namespaceystem.Windows.Forms.Integration;assembly=WindowsFormsIntegration'. Line '1' Position '1284'."

I don't know why.
Thanks for any input.
 
P

Pavel Minaev

Haiping said:
I use XamlWriter to write a UserControl to xaml string. The UserControl
has
the following namespace:
xmlns:wfi="clr-namespaceystem.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
But the xaml string does not have the WindowsFormsIntegration namespace.
It
also has <av:WindowsFormsHost>.

So, what namespace is the "av" prefix mapped to at that point?
I added WindowsFormsIntegration namespace in
the xaml string and change <av:WindowsFormsHost> to
<wfi:WindowsFormsHost>.

Can you show your XAML (the bits relevant to this discussion)? It's quite
hard to follow your description, the code would be much easier to deal with.
When XamlReader parse a xaml string it throws the following exception:
"The tag 'WindowsFormsHost' does not exist in XML namespace
'clr-namespaceystem.Windows.Forms.Integration;assembly=WindowsFormsIntegration'.
Line '1' Position '1284'."

If the string is as written above, then I imagine it would complain. It
should be "clr-namespace:System...".

Unless you've made a typo twice. In which case, again, it is still better to
disambiguate by showing the code (actual code though, please, not a
re-type - to avoid typos).
 
P

Pavel Minaev

Haiping said:
I use XamlWriter to write a UserControl to xaml string. The UserControl
has
the following namespace:
xmlns:wfi="clr-namespaceystem.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
But the xaml string does not have the WindowsFormsIntegration namespace.
It
also has <av:WindowsFormsHost>.

So, what namespace is the "av" prefix mapped to at that point?
I added WindowsFormsIntegration namespace in
the xaml string and change <av:WindowsFormsHost> to
<wfi:WindowsFormsHost>.

Can you show your XAML (the bits relevant to this discussion)? It's quite
hard to follow your description, the code would be much easier to deal with.
When XamlReader parse a xaml string it throws the following exception:
"The tag 'WindowsFormsHost' does not exist in XML namespace
'clr-namespaceystem.Windows.Forms.Integration;assembly=WindowsFormsIntegration'.
Line '1' Position '1284'."

If the string is as written above, then I imagine it would complain. It
should be "clr-namespace:System...".

Unless you've made a typo twice. In which case, again, it is still better to
disambiguate by showing the code (actual code though, please, not a
re-type - to avoid typos).
 
H

Haiping

Hi Pavel,
I found the problem. Now the XamlReader works.
XamlWriter writes xaml string it does not load WindowsFormsIntegration.
After I do the following repeacements the XamlReader can read the Xaml string.

string xamlStringWithWfi =
originalString.Replace("DockSite.IsDocument=\"True\" ",
"DockSite.IsDocument=\"True\"
xmlns:wfi=\"clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration\" ");

xamlString = xamlStringWithWfi.Replace("av:WindowsFormsHost>",
"wfi:WindowsFormsHost>");

Thanks for your help,
 
H

Haiping

Hi Pavel,
I found the problem. Now the XamlReader works.
XamlWriter writes xaml string it does not load WindowsFormsIntegration.
After I do the following repeacements the XamlReader can read the Xaml string.

string xamlStringWithWfi =
originalString.Replace("DockSite.IsDocument=\"True\" ",
"DockSite.IsDocument=\"True\"
xmlns:wfi=\"clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration\" ");

xamlString = xamlStringWithWfi.Replace("av:WindowsFormsHost>",
"wfi:WindowsFormsHost>");

Thanks for your help,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top