Ejemplo n.º 1
0
 protected override void OnAttached()
 {
     base.OnAttached();
     binding           = new Binding();
     binding.XPath     = XPath + "/" + CustomNode.Name;
     binding.Mode      = BindingMode.OneWay;
     binding.Converter = NodeAvailableConverter.Instance;
     AssociatedObject.SetBinding(CheckBox.IsCheckedProperty, binding);
     AssociatedObject.Click += new RoutedEventHandler(AssociatedObject_Click);
     SourceProv.Refresh();
 }
Ejemplo n.º 2
0
    void AssociatedObject_Click(object sender, RoutedEventArgs e)
    {
        var parent = SourceProv.Document.SelectSingleNode(XPath);

        if (AssociatedObject.IsChecked == true)
        {
            var newelement = SourceProv.Document.CreateElement(CustomNode.Name);
            foreach (var at in CustomNode.Attributes)
            {
                newelement.SetAttribute(at.Name, at.Value);
            }
            parent.AppendChild(newelement);
        }
        else if (AssociatedObject.IsChecked == false)
        {
            parent.RemoveChild(parent.SelectSingleNode(CustomNode.Name));
        }
        SourceProv.Refresh();
        AssociatedObject.SetBinding(CheckBox.IsCheckedProperty, binding);
    }