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 6762893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:24:45+00:00 2026-05-26T14:24:45+00:00

I’m new to C# programming so here goes.. I’m trying to write an electronic

  • 0

I’m new to C# programming so here goes..

I’m trying to write an electronic scrapbook application as a present but I’ve come unstuck – my application currently shows the first xml record but I don’t know how to use the next button to go to the next record. I’ve tried experimenting with arrays and arraylists but I can’t seem to get anywhere near what I’m looking for. Any help would be hugely appreciated 🙂

I’ll include my XML and XAML code below but I’ll leave out the C# code as it’ll make my post too long. Apologies if any of the code below is irrelevant to you:

XAML:

    <Grid>
    <Grid.DataContext>
        <XmlDataProvider Source="Data/Memories.xml" XPath="/Memories/Memory" />
    </Grid.DataContext>
    <DockPanel Height="22" Name="dockPanel1" HorizontalAlignment="Stretch" VerticalAlignment="Top" Width="Auto">
        <Menu Height="24" Name="menu1" Width="Auto" DockPanel.Dock="Top" VerticalAlignment="Top">
            <MenuItem Header="_File" >
                <MenuItem Header="Add _New Memory" Name="newMemory" Click="newMemory_Click" />
                <MenuItem Header="_Edit this Memory" Name="editMemory" Click="editMemory_Click" />
                <MenuItem Header="_Delete this Memory" Name="deleteMemory" Click="deleteMemory_Click" />
                <MenuItem Header="_Save Changes" Name="saveMemory" Click="saveMemory_Click" />
                <Separator/>
                <MenuItem Header="E_xit" Name="exit" Click="exit_Click" />
            </MenuItem>
            <MenuItem Header="_Edit" />
            <MenuItem Header="_Help" >
                <MenuItem Header="_About muh program" Name="about" Click="about_Click" />
            </MenuItem>
        </Menu>
    </DockPanel>
    <Button Content="&lt;" Margin="-70,32,0,0" Name="previousButton" Height="22" Width="20" VerticalAlignment="Top" Visibility="{Binding IsEnabled, ElementName=newMemory, Converter={StaticResource VisibleIfTrue}}" />
    <Button Content=">" Height="22" Margin="70,32,0,0" Name="nextButton" Width="20" VerticalAlignment="Top" Visibility="{Binding IsEnabled, ElementName=newMemory, Converter={StaticResource VisibleIfTrue}}" />
    <Button Content="?" Margin="0,32,0,0" Name="RandomButton" Height="22" Width="40" VerticalAlignment="Top" Visibility="{Binding IsEnabled, ElementName=newMemory, Converter={StaticResource VisibleIfTrue}}" />
    <TextBlock Height="30" Width="300" Margin="0,62,0,419" TextAlignment="Center" Text="{Binding XPath=@Title}" FontSize="15" FontWeight="Bold" Name="memoryTitle" />
    <TextBlock Height="30" Width="300" Margin="0,84,0,397" TextAlignment="Center" Text="{Binding XPath=./Date}" FontSize="12" FontWeight="Normal" Name="memoryDate" Panel.ZIndex="1" />
    <TextBlock Height="375" HorizontalAlignment="Right" Margin="0,116,26,20" Name="textOutput" Width="300" TextWrapping="Wrap" TextAlignment="Center" Background="White" Visibility="{Binding IsEnabled, ElementName=newMemory, Converter={StaticResource VisibleIfTrue}}">
        <TextBlock.Text>
            <Binding XPath="./Blurb" />
        </TextBlock.Text>
    </TextBlock>
    <TextBox HorizontalAlignment="Right" Margin="0,116,26,20" Name="textInput" Height="375" Width="300" TextWrapping="Wrap" AcceptsReturn="True" Visibility="{Binding IsEnabled, ElementName=newMemory, Converter={StaticResource VisibleIfNotTrue}}" />
    <Image Height="375" HorizontalAlignment="Center" Margin="-326,94,0,0" Name="imgPhoto" Stretch="Uniform" VerticalAlignment="Center" Width="500" ClipToBounds="False" AllowDrop="False" Source="{Binding XPath=ImageFile}" />
    <Image Height="375" HorizontalAlignment="Center" Margin="-326,94,0,0" Name="imgPhotoNew" Stretch="Uniform" VerticalAlignment="Center" Width="500" ClipToBounds="False" AllowDrop="False" Visibility="{Binding IsEnabled, ElementName=newMemory, Converter={StaticResource VisibleIfNotTrue}}" />
    <Button Content="Done" Height="22" Width="40" Margin="463,32,375,0" Name="doneMemoryButton" VerticalAlignment="Top" Click="doneMemoryButton_Click" Visibility="{Binding IsEnabled, ElementName=newMemory, Converter={StaticResource VisibleIfNotTrue}}" />
    <Button Content="Select Photo" Height="22" Width="75" Margin="377,32,427,0"  Name="selectPhotoButton" VerticalAlignment="Top" HorizontalAlignment="Center" Click="selectPhotoButton_Click" Visibility="{Binding IsEnabled, ElementName=newMemory, Converter={StaticResource VisibleIfNotTrue}}" />
</Grid>

XML:

<Memories>
   <Memory Title="1 Year - Howard Jones!" ID="1">
      <ImageFile>Data/Images/01.jpg</ImageFile>
      <Blurb>We saw Howard Jones perform!!</Blurb>
      <Date>06/11/2010</Date>
   </Memory>
   <Memory Title="Ski Holiday" ID="2">
      <ImageFile>Data/Images/02.jpg</ImageFile>
      <Blurb>Our skiing holiday in Flaine!</Blurb>
      <Date>29/11/2010</Date>
   </Memory>
   <Memory Title="Stinksy's Birthday: Ice Bar!" ID="3">
      <ImageFile>Data/Images/03.jpg</ImageFile>
      <Blurb>Absolut Ice Bar</Blurb>
      <Date>19/12/2010</Date>
   </Memory>
</Memories>
  • 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-05-26T14:24:46+00:00Added an answer on May 26, 2026 at 2:24 pm

    I will not work through that code but i can give you a simple example of how to do this:

    <Window.Resources>
        <XmlDataProvider x:Key="data" Source="Data/Memories.xml" XPath="/Memories/Memory" />
        <CollectionViewSource x:Key="dataCvs" Source="{StaticResource data}" />
    </Window.Resources>
    <StackPanel>
        <ContentControl Content="{Binding Source={StaticResource dataCvs}}">
            <ContentControl.ContentTemplate>
                <DataTemplate>
                    <StackPanel>
                        <Image Source="{Binding XPath=ImageFile}" />
                        <TextBlock Text="{Binding XPath=Blurb}" />
                        <TextBlock Text="{Binding XPath=Date}" />
                    </StackPanel>
                </DataTemplate>
            </ContentControl.ContentTemplate>
        </ContentControl>
        <Button Content="Previous" Click="Previous_Click" Tag="{StaticResource dataCvs}" />
        <Button Content="Next" Click="Next_Click" Tag="{StaticResource dataCvs}" />
    </StackPanel>
    

    The ContentControl binds to the CurrentItem of the view on top of the memories collection, i pass the CollectionViewSource to the Buttons so i can change the current item on click. (Normally you should use a Command and pass it as CommandParameter instead, that is cleaner)

    private void Next_Click(object sender, RoutedEventArgs e)
    {
        var button = (Button)sender;
        var cvs = (CollectionViewSource)button.Tag;
        cvs.View.MoveCurrentToNext();
    }
    
    private void Previous_Click(object sender, RoutedEventArgs e)
    {
        var button = (Button)sender;
        var cvs = (CollectionViewSource)button.Tag;
        cvs.View.MoveCurrentToPrevious();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.