Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

Error with set namespaces in Xaml

$
0
0

I have an app which is generating Xaml for a WPF application. The problem is that when generating the XML each element is given a blank xmlns=" " within each element node which is breaking the Xaml. How do I prevent the xmlns=" " from been outputted in the Xaml file?

If I remove the xmlns=" " from the Xaml the form is correct, or if I add a button, the auto generated code looks the same as the button code of the visually added button

 The generating code looks like this :-

XmlDocument

doc = newXmlDocument();

doc.Load(xamlFile.Document.FullName);   

XmlNodeListnodes = doc.GetElementsByTagName("Grid");

XmlNode node = node.Item(0);

...

XmlElement xmlElement = doc.CreateElement("Button");

...  set attributes

node.AppendChild(xmlElement);

doc.save(..);

The resultant errored Xaml looks like this

<

<Window x:Class="WindowsFormsApplication_UWP.Form1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Form1" Height="300" Width="300"><Grid><Button Name="btnOne" Width="134" Height="101" Margin="42,66,0,0" Content="btnOne" HorizontalAlignment="Left" VerticalAlignment="Top" Click="btnOne_Click" xmlns=" " /></Grid></Window>





Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>