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>