nosbor
nosbor

Reputation: 2999

How to do slide show in wpf. Changing windows content like slide show

I want to display window and when user will click a button then show for him next content in the same window. And I want also to do a animation. Is it possible? Animation is not important. I only want to change content dynamicaly. I cant find it anywhere...

Please give me simplier solution for this without any frameworks.

Content is not only images. There will be many controls.

I'm using WPF with .NET Framework 4.0

Upvotes: 2

Views: 3843

Answers (4)

Code0987
Code0987

Reputation: 2618

Are you looking for http://transitionals.codeplex.com/ ?

"Transitionals is a framework for building and using WPF transitions which provide an easy way to switch between UI views in a rich and animated way."

Upvotes: 0

Jens
Jens

Reputation: 25583

One way to approach this without a lot of overhead would be to prepare all slides of the slideshow as UserControls, let the main window have a

<ContentPresenter x:Name="CurrentSlidePresenter" />

and use

UserControl currentSlide = GetCurrentSlide(); // implement this to your liking
CurrentSlidePresenter.Content = currentSlide;

in the button click handler.

This approach can be expanded to use animation using FluidKit.

Upvotes: 3

Bek Raupov
Bek Raupov

Reputation: 3777

in short, you will have to StoryBoard and Trigger Animation technologies in WPF. Google for "WPF Window Sliding Animation Example".

Found this useful

Upvotes: 0

Maxim V. Pavlov
Maxim V. Pavlov

Reputation: 10509

The simple solution would be to just load content from xaml in your project with XamlReader class.

Here is a link: http://blogs.msdn.com/b/ashish/archive/2007/08/14/dynamically-loading-xaml.aspx

Simplified code from the link:

public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
            LoadXAMLMethod(); 
        }


        public void LoadXAMLMethod()
        {
            try
            {
                StreamReader mysr = new StreamReader("Page1.xaml");
                DependencyObject rootObject = XamlReader.Load(mysr.BaseStream) as DependencyObject;

                this.Content = rootObject;
            }
            catch (FileNotFoundException ex)
            {
                MessageBox.Show(ex.Message.ToString());    
            }
        }
    }
}

P.S. Evading more reliable approaches, such as using MVVM is not a good thing. You should consider at some point to get acquainted with MVVM, if you are to solve such UI-manipulation tasks often.

Upvotes: 1

Related Questions