예제 #1
0
        public UIElement GetEditor(XmlNode nd)
        {
            DataGrid dataGrid = new DataGrid()
            {
                CanUserReorderColumns = true,
                CanUserResizeColumns  = true
            };

            ObservableCollection <Row2> rows = new ObservableCollection <Row2>();

            foreach (XmlNode child in nd.ChildNodes)
            {
                Row2 r = new Row2();

                var attr = child.Attributes["Name"];
                if (attr != null)
                {
                    r.Name = attr.Value;
                }

                attr = child.Attributes["Equipment"];
                if (attr != null)
                {
                    r.Equipment = attr.Value;
                }

                attr = child.Attributes["Command"];
                if (attr != null)
                {
                    r.Command = attr.Value;
                }

                rows.Add(r);
            }
            dataGrid.ItemsSource = rows;

            return(dataGrid);
        }
예제 #2
0
        public XmlNode Save(UIElement control, XmlNode nd)
        {
            XmlDocument xd = nd.OwnerDocument;
            XmlElement  el = xd.CreateElement(node);

            DataGrid dataGrid = (DataGrid)control;

            foreach (var item in dataGrid.Items)
            {
                if (item is Row2)
                {
                    Row2 r = (Row2)item;

                    XmlElement child = xd.CreateElement("Command");
                    child.SetAttribute("Name", r.Name);
                    child.SetAttribute("Equipment", r.Equipment);
                    child.SetAttribute("Command", r.Command);

                    el.AppendChild(child);
                }
            }

            return(el);
        }