Как обновить данные XML?

На форме два RadioButton, код XAML:

<Window x:Class="UpdateXML.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:UpdateXML"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">

    <Window.Resources>
        <local:BoolInverterConverter x:Key="BoolInverterConverter" />
    </Window.Resources>

    <Window.DataContext>
        <XmlDataProvider IsInitialLoadEnabled="True" IsAsynchronous="False">
            <x:XData>
                <Product xmlns="">
                    <Settings>
                        <Resume title="Резюме">
                            <Type>
                                <Item key="1" title="Годен"/>
                                <Item key="2" title="Брак"/>
                            </Type>
                        </Resume>
                        <Slot>
                            <Item key="01" resume ="" />
                        </Slot>
                    </Settings>
                </Product>
            </x:XData>
        </XmlDataProvider>
    </Window.DataContext>
        
    <Grid>
        <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
                <RadioButton GroupName="{Binding XPath='@key'}" Content="{Binding XPath='//Resume/Type/Item[1]/@title'}" IsChecked="{Binding PropertyValue}"/>
                <RadioButton GroupName="{Binding XPath='@key'}" Content="{Binding XPath='//Resume/Type/Item[2]/@title'}" IsChecked="{Binding PropertyValue, 
                                    Converter={StaticResource BoolInverterConverter}}" />
        </StackPanel>
    </Grid>
</Window>

Code-behind:

using System;
using System.Windows;
using System.Windows.Data;

namespace UpdateXML
{
    /// <summary>
    /// Логика взаимодействия для MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    }

    public class BoolInverterConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter,
            System.Globalization.CultureInfo culture)
        {
            if (value is bool)
            {
                return !(bool)value;
            }
            return value;
        }

        public object ConvertBack(object value, Type targetType, object parameter,
            System.Globalization.CultureInfo culture)
        {
            if (value is bool)
            {
                return !(bool)value;
            }
            return value;
        }

        #endregion
    }
}

На форме это выглядит так:

введите сюда описание изображения

Как можно сделать так, чтобы выбор в виде "Годен/Брак" был записан в атрибут "resume" тега "Item" в теге "Slot": введите сюда описание изображения


Ответы (0 шт):