private void NavigateToSelectedPage() { if (ListaMenusKallpaBox.SelectedValue is Uri source) { ContenedorVentanas?.Navigate(source); } MenuToggleButton.IsChecked = false; }
private void serializar() { string savedButton = System.Windows.Markup.XamlWriter.Save(contenedorVentanas); StringReader stringReader = new StringReader(savedButton); XmlReader xmlReader = XmlReader.Create(stringReader); StringBuilder outstr = new StringBuilder(); //this code need for right XML fomating XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.OmitXmlDeclaration = true; XamlDesignerSerializationManager dsm = new XamlDesignerSerializationManager(XmlWriter.Create(outstr, settings)); //this string need for turning on expression saving mode dsm.XamlWriterMode = XamlWriterMode.Expression; System.Windows.Markup.XamlWriter.Save(contenedorVentanas, dsm); String convertido = outstr.ToString(); StringReader stringReader2 = new StringReader(convertido); XmlReader xmlReader2 = XmlReader.Create(stringReader2); ContenedorVentanas readerLoadButton = (ContenedorVentanas)System.Windows.Markup.XamlReader.Load(xmlReader2); //System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(ContenedorVentanas)); //using (var writer = new StreamWriter(@"d:\test.xml")) //{ // serializer.Serialize(writer, contenedorVentanas); //} //MemoryStream ms = new MemoryStream(); //BinaryFormatter bf = new BinaryFormatter(); //bf.Serialize(ms, this); /// data is the class i wanna serialize. //ms.Seek(0, 0); //StreamReader rdr = new StreamReader(ms); //string str = rdr.ReadToEnd(); //byte[] byteArray = Encoding.ASCII.GetBytes(str); //XamlSerializer xs = new XamlSerializer(); //xs.DiscoverAttachedProperties(typeof(AttachedProps)); //string text = xs.Serialize(this.nestedObject); }