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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:57:06+00:00 2026-06-13T17:57:06+00:00

i’m using example take from project japf_fr_slide_animation. i’ve added button to trigger appropriate page

  • 0

i’m using example take from project “japf_fr_slide_animation”. i’ve added button to trigger appropriate page but is stuck and dont know how to trigger them. Here are all the pages to the referenced project with the added buttons. Can anyone help on how I can trigger the pages based on the button?

view1.xaml

<UserControl x:Class="FirstTry.view1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="300" Width="300">
    <Grid Background="LightBlue">
        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Top" Text="view1" />
        <Button Name="show2" Content="show second xaml" VerticalAlignment="Center" Width="150"></Button>
    </Grid>
</UserControl>

view2.xaml

<UserControl x:Class="FirstTry.view2"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="300" Width="300">
    <Grid Background="LightCoral">
        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Top" Text="view2"/>
        <Button Name="show3" Content="show third xaml" VerticalAlignment="Center" Width="150"></Button>
    </Grid>
</UserControl>

view3.xaml

<UserControl x:Class="FirstTry.view3"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="300" Width="300">
    <Grid Background="LightGreen">
        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Top" Text="view3"/>
        <Button Name="show1" Content="show first xaml" VerticalAlignment="Center" Width="150"></Button>
    </Grid>
</UserControl>

Window1.xaml

<Window x:Class="FirstTry.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" SizeToContent="WidthAndHeight" ResizeMode="NoResize">

    <Window.Resources>
        <XmlDataProvider x:Key="views">
            <x:XData>
                <Views xmlns="">
                    <View Title="View1">
                        <Page Source="view1.xaml"/> 
                    </View>
                    <View Title="View2">
                        <Page Source="view2.xaml"/>
                    </View>
                    <View Title="View3">
                        <Page Source="view3.xaml"/>
                    </View>
                </Views>
            </x:XData>
        </XmlDataProvider>

        <Storyboard x:Key="slideLeftToRight"  
                    TargetProperty="RenderTransform.(TranslateTransform.X)"
                    AccelerationRatio=".4"
                    DecelerationRatio=".4">
            <DoubleAnimation Storyboard.TargetName="viewer" Duration="0:0:0.6" From="300" To="0"/>
            <DoubleAnimation Storyboard.TargetName="bordervisual" Duration="0:0:0.6" From="0" To="-300"/>
        </Storyboard>

        <Storyboard x:Key="slideRightToLeft" 
                    TargetProperty="RenderTransform.(TranslateTransform.X)"
                    AccelerationRatio=".4"
                    DecelerationRatio=".4">
            <DoubleAnimation Storyboard.TargetName="viewer" Duration="0:0:0.6" From="-300" To="0"/>
            <DoubleAnimation Storyboard.TargetName="bordervisual" Duration="0:0:0.6" From="0" To="300"/>
        </Storyboard>

        <VisualBrush x:Key="VisualBrush1" Visual="{Binding ElementName=viewer}"/>

    </Window.Resources>

    <Grid>
        <StackPanel>

            <StackPanel Orientation="Horizontal">
                <ListBox x:Name="viewList" Height="20" Width="300" SelectedIndex="0"
                    ItemsSource="{Binding Source={StaticResource views}, XPath=Views/View}"
                    DisplayMemberPath="@Title"                    
                    SelectionChanged="viewList_SelectionChanged">
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal"/>
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                </ListBox>
            </StackPanel>

            <Grid Width="300" Height="300">



                <Border x:Name="bordervisual" Width="300">
                    <Rectangle x:Name="rectanglevisual"/>
                    <Border.RenderTransform>
                        <TranslateTransform/>
                    </Border.RenderTransform>
                </Border>

                <ItemsControl x:Name="viewer" DataContext="{Binding Path=SelectedItem, ElementName=viewList}"
                    ItemsSource="{Binding XPath=Page}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Frame x:Name="frame" Source="{Binding XPath=@Source}"/>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                    <ItemsControl.RenderTransform>
                        <TranslateTransform/>
                    </ItemsControl.RenderTransform>
                </ItemsControl>
            </Grid>
        </StackPanel>       
    </Grid>
</Window>

Window1.xaml.cs

public partial class Window1 : Window
    {
        private static int oldSelectedIndex = 0;

        public Window1()
        {
            InitializeComponent();
        }

        public RenderTargetBitmap RenderBitmap(FrameworkElement element)
        {
            double topLeft = 0;
            double topRight = 0;
            int width = (int)element.ActualWidth;
            int height = (int)element.ActualHeight;
            double dpiX = 96; // this is the magic number
            double dpiY = 96; // this is the magic number

            PixelFormat pixelFormat = PixelFormats.Default;
            VisualBrush elementBrush = new VisualBrush(element);
            DrawingVisual visual = new DrawingVisual();
            DrawingContext dc = visual.RenderOpen();

            dc.DrawRectangle(elementBrush, null, new Rect(topLeft, topRight, width, height));
            dc.Close();

            RenderTargetBitmap bitmap = new RenderTargetBitmap(width, height, dpiX, dpiY, pixelFormat);

            bitmap.Render(visual);
            return bitmap;
        } 

        private void viewList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            XmlElement root = (XmlElement)viewer.DataContext;
            XmlNodeList xnl = root.SelectNodes("Page");

            if (viewer.ActualHeight > 0 && viewer.ActualWidth > 0)
            {
                RenderTargetBitmap rtb = RenderBitmap(viewer);
                rectanglevisual.Fill = new ImageBrush(BitmapFrame.Create(rtb));
            }

            viewer.ItemsSource = xnl;

            if (oldSelectedIndex < viewList.SelectedIndex)
            {
                viewer.BeginStoryboard((Storyboard)this.Resources["slideLeftToRight"]);
            }
            else
            {
                viewer.BeginStoryboard((Storyboard)this.Resources["slideRightToLeft"]);
            }

            oldSelectedIndex = viewList.SelectedIndex;
        }
    }
  • 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-13T17:57:08+00:00Added an answer on June 13, 2026 at 5:57 pm

    A pretty simple way to do this, would be to have a command fire from each of the buttons, whenever they are being clicked. The new page number that should be selected, could be sent to the command by passing a parameter to it.

    In the Window we can create a binding to the command, so it receives notifications when a button is clicked, and we can then select the new page in the ListBox, which causes the animation to run.

    I have written some code that demonstrates this, and just adds a little to what you have already:

    view1.xaml

    <UserControl x:Class="FirstTry.view1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:FirstTry"
        Height="300" Width="300">
        <Grid Background="LightBlue">
            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Top" Text="view1" />
    
            <!-- Button fires command with the value 1 as next pageindex --> 
            <Button Name="show2" Content="show second xaml" VerticalAlignment="Center" Width="150"
                    Command="{x:Static local:Commands.SlideToPage}" CommandParameter="1"></Button>
        </Grid>
    </UserControl>
    

    view2.xaml

    <UserControl x:Class="FirstTry.view2"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:FirstTry"
        Height="300" Width="300">
        <Grid Background="LightCoral">
            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Top" Text="view2"/>
    
            <!-- Button fires command with the value 2 as next pageindex -->
            <Button Name="show3" Content="show third xaml" VerticalAlignment="Center" Width="150"
                    Command="{x:Static local:Commands.SlideToPage}" CommandParameter="2 </Button>
        </Grid>
    </UserControl>
    

    view3.xaml

    <UserControl x:Class="FirstTry.view3"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:FirstTry"
        Height="300" Width="300">
        <Grid Background="LightGreen">
            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Top" Text="view3"/>
    
            <!-- Button fires command with the value 0 as next pageindex -->
            <Button Name="show1" Content="show first xaml" VerticalAlignment="Center" Width="150"
                    Command="{x:Static local:Commands.SlideToPage}" CommandParameter="0"></Button>
        </Grid>
    </UserControl>
    

    Window1.xaml

    <Window x:Class="FirstTry.Window1"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:local="clr-namespace:FirstTry"
            Title="MainWindow" SizeToContent="WidthAndHeight" ResizeMode="NoResize">
        <Window.CommandBindings>
            <!-- Make the window listen for the SlideToPage command -->
            <CommandBinding Command="{x:Static local:Commands.SlideToPage}"
                            CanExecute="SlideToPage_CanExecute"
                            Executed="SlideToPage_Executed" />
        </Window.CommandBindings>
    
        <Window.Resources>
            <XmlDataProvider x:Key="views">
                <x:XData>
                    <Views xmlns="">
                        <View Title="View1">
                            <Page Source="view1.xaml"/> 
                        </View>
                        <View Title="View2">
                            <Page Source="view2.xaml"/>
                        </View>
                        <View Title="View3">
                            <Page Source="view3.xaml"/>
                        </View>
                    </Views>
                </x:XData>
            </XmlDataProvider>
    
            <Storyboard x:Key="slideLeftToRight"  
                        TargetProperty="RenderTransform.(TranslateTransform.X)"
                        AccelerationRatio=".4"
                        DecelerationRatio=".4">
                <DoubleAnimation Storyboard.TargetName="viewer" Duration="0:0:0.6" From="300" To="0"/>
                <DoubleAnimation Storyboard.TargetName="bordervisual" Duration="0:0:0.6" From="0" To="-300"/>
            </Storyboard>
    
            <Storyboard x:Key="slideRightToLeft" 
                        TargetProperty="RenderTransform.(TranslateTransform.X)"
                        AccelerationRatio=".4"
                        DecelerationRatio=".4">
                <DoubleAnimation Storyboard.TargetName="viewer" Duration="0:0:0.6" From="-300" To="0"/>
                <DoubleAnimation Storyboard.TargetName="bordervisual" Duration="0:0:0.6" From="0" To="300"/>
            </Storyboard>
    
            <VisualBrush x:Key="VisualBrush1" Visual="{Binding ElementName=viewer}"/>
        </Window.Resources>
    
        <Grid>
            <StackPanel>
    
                <StackPanel Orientation="Horizontal">
                    <ListBox x:Name="viewList" Height="20" Width="300" SelectedIndex="0"
                        ItemsSource="{Binding Source={StaticResource views}, XPath=Views/View}"
                        DisplayMemberPath="@Title"                    
                        SelectionChanged="viewList_SelectionChanged">
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel Orientation="Horizontal"/>
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
                    </ListBox>
                </StackPanel>
    
                <Grid Width="300" Height="300">
                    <Border x:Name="bordervisual" Width="300">
                        <Rectangle x:Name="rectanglevisual"/>
                        <Border.RenderTransform>
                            <TranslateTransform/>
                        </Border.RenderTransform>
                    </Border>
    
                    <ItemsControl x:Name="viewer" DataContext="{Binding Path=SelectedItem, ElementName=viewList}"
                        ItemsSource="{Binding XPath=Page}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <Frame x:Name="frame" Source="{Binding XPath=@Source}"/>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                        <ItemsControl.RenderTransform>
                            <TranslateTransform/>
                        </ItemsControl.RenderTransform>
                    </ItemsControl>
                </Grid>
            </StackPanel>       
        </Grid>
    </Window>
    

    Window1.xaml.cs

    public partial class Window1 : Window
    {
        private static int oldSelectedIndex = 0;
    
        public Window1()
        {
            InitializeComponent();
        }
    
        public RenderTargetBitmap RenderBitmap(FrameworkElement element)
        {
            double topLeft = 0;
            double topRight = 0;
            int width = (int)element.ActualWidth;
            int height = (int)element.ActualHeight;
            double dpiX = 96; // this is the magic number
            double dpiY = 96; // this is the magic number
    
            PixelFormat pixelFormat = PixelFormats.Default;
            VisualBrush elementBrush = new VisualBrush(element);
            DrawingVisual visual = new DrawingVisual();
            DrawingContext dc = visual.RenderOpen();
    
            dc.DrawRectangle(elementBrush, null, new Rect(topLeft, topRight, width, height));
            dc.Close();
    
            RenderTargetBitmap bitmap = new RenderTargetBitmap(width, height, dpiX, dpiY, pixelFormat);
    
            bitmap.Render(visual);
            return bitmap;
        }
    
        private void viewList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            XmlElement root = (XmlElement)viewer.DataContext;
            XmlNodeList xnl = root.SelectNodes("Page");
    
            if (viewer.ActualHeight > 0 && viewer.ActualWidth > 0)
            {
                RenderTargetBitmap rtb = RenderBitmap(viewer);
                rectanglevisual.Fill = new ImageBrush(BitmapFrame.Create(rtb));
            }
    
            viewer.ItemsSource = xnl;
    
            if (oldSelectedIndex < viewList.SelectedIndex)
            {
                viewer.BeginStoryboard((Storyboard)this.Resources["slideLeftToRight"]);
            }
            else
            {
                viewer.BeginStoryboard((Storyboard)this.Resources["slideRightToLeft"]);
            }
    
            oldSelectedIndex = viewList.SelectedIndex;
        }
    
        private void SlideToPage_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            //The command can always be executed
            e.CanExecute = true;
        }
    
        private void SlideToPage_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            //When the command is executed, we find the new pagenumber passed as a parameter
            //and switch the selected item of the ListBox, so the animation will run.
            int pagenumber = 0;
    
            if (int.TryParse(e.Parameter.ToString(), out pagenumber))
            {
                viewList.SelectedIndex = pagenumber;
            }
        } 
    }
    

    Commands.cs

    using System;
    using System.Windows.Input;
    
    namespace FirstTry
    {
        public static class Commands
        {
            public static readonly RoutedCommand SlideToPage = new RoutedCommand();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
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
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.