Exemple #1
0
        void UpdateXaml()
        {
            var sb = new StringBuilder();

            using (var xmlWriter = XmlWriter.Create(sb)) {
                DesignSurface.SaveDesigner(xmlWriter);
                Text = XamlFormatter.Format(sb.ToString());
            }
        }
Exemple #2
0
        void UpdateXaml()
        {
            var sb = new StringBuilder();

            using (var xmlWriter = new XamlXmlWriter(sb)) {
                DesignSurface.SaveDesigner(xmlWriter);
                Dictionary <XamlElementLineInfo, XamlElementLineInfo> d;
                Text = XamlFormatter.Format(sb.ToString(), out d);

                if (DesignSurface.DesignContext.Services.Selection.PrimarySelection != null)
                {
                    var item = DesignSurface.DesignContext.Services.Selection.PrimarySelection;
                    var line = ((PositionXmlElement)((XamlDesignItem)item).XamlObject.XmlElement).LineNumber;
                    var pos  = (((XamlDesignItem)item).XamlObject.PositionXmlElement).LinePosition;
                    var newP = d.FirstOrDefault(x => x.Key.LineNumber == line && x.Key.LinePosition == pos);
                    XamlElementLineInfo = newP.Value;
                }
            }
        }