Reputation: 2999
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
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
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
Reputation: 3777
in short, you will have to StoryBoard and Trigger Animation technologies in WPF. Google for "WPF Window Sliding Animation Example".
Upvotes: 0
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