Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9115449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:26:07+00:00 2026-06-17T04:26:07+00:00

I am using following code to display the content of an XML file in

  • 0

I am using following code to display the content of an XML file in a ListBox and to display the selected content in two TextBoxes.

<?xml version="1.0" encoding="utf-8"?>
<Window
    x:Class="XML_View_Edit.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow"
    Width="500"
    Height="200">
    <Window.Resources>
        <XmlDataProvider x:Key="InventoryData"
                         XPath="Inventory/Books"
                         Source="Data.xml"/>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition
                Height="100" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <ListBox
            Grid.Row="0"
            Name="listBox1" >
            <ListBox.ItemsSource>
                <Binding Source="{StaticResource InventoryData}" XPath="Book"/>
            </ListBox.ItemsSource>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text = "{Binding XPath=Title}" />
                        <TextBlock Text= " - " />
                        <TextBlock Text = "{Binding XPath=Summary}" />
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <Grid
            Grid.Row="1"
             DataContext="{Binding ElementName=listBox1, Path=SelectedItem}">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition
                    Width="70" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Label
                Content="Title"
                Grid.Row="0"
                Grid.Column="0"
                Name="label_title" />
            <Label
                Content="Summary"
                Grid.Row="1"
                Grid.Column="0"
                Name="label_summary" />
            <TextBox
                Grid.Column="1"
                Name="textbox_title"
                Text = "{Binding XPath=Title}"
                Grid.Row="0" />
            <TextBox
                Grid.Column="1"
                Name="textbox_summary"
                Text = "{Binding XPath=Summary}"
                Grid.Row="1" />
        </Grid>
    </Grid>
</Window>

The user can change the text in the TextBoxes and this is also synchronized with the content of the ListBox. But how can I save/synchronize the changes in/with the XML file?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:26:09+00:00Added an answer on June 17, 2026 at 4:26 am

    In an eventhandler (buttonClick or windowClose) you can access the resource:

    var provider = Resources["inventoryData"] as XmlDataProvider;
    

    and provider has a Document property. I’m not sure if you can overwrite but something like:

    provider.Document.Save(newFileName);
    

    or

    provider.Document.Save(provider.Source.ToString());  // existing file name
    

    should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following code to read the content of a PDF file: string
i have a xsl file as below: -------Begin------ <?xml version=1.0 encoding=utf-8?> <xsl:stylesheet version=2.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform
Something's screwy here. I'm trying to parse this XSL file: <?xml version=1.0 encoding=utf-8?> <xsl:stylesheet
Hello there I am using the following code for display the requested content.It is
I am using the following code for 1) Display the changed content in DIV
I am using the following code to display an index for a TableView. My
Using the following code, I am able to display up to 10 images. What
I am using the following code on my site to display a thumbnail produced
I am using the following code to try and display in a time in
I have the following code to display an image in imagebox using EmgucV: Capture

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.