Click here to Skip to main content
15,867,704 members
Articles / Desktop Programming / WPF

Creating an Animated ContentControl

Rate me:
Please Sign up or sign in to vote.
4.87/5 (38 votes)
15 Dec 2010CPOL4 min read 100.8K   5.9K   56  
Shows how to build a content control which animates transitions between content.
<Window x:Class="AnimatedContentControlSample.MainWindow"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:local="clr-namespace:AnimatedContentControlSample"
		xmlns:view="clr-namespace:AnimatedContentControlSample.Views"
		xmlns:vm="clr-namespace:AnimatedContentControlSample.ViewModels"
		Title="MainWindow" Height="350" Width="525">
	<Window.Resources>
		<DataTemplate DataType="{x:Type vm:MyContentViewModel}">
			<view:MyContentView />
		</DataTemplate>		
	</Window.Resources>
	<Window.DataContext>
		<vm:MainWindowViewModel />
	</Window.DataContext>
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="*" />
		</Grid.RowDefinitions>
		<Button Command="{Binding ChangeContentCommand}" Content="Change Content" FontSize="20" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10" Padding="10,5" />
		<local:AnimatedContentControl Content="{Binding Content}" Grid.Row="1" />
	</Grid>
</Window>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer ABB
Sweden Sweden
My name is Isak Savo and I work as a Research Engineer at ABB Corporate Research in Västerås, Sweden. My work is focused around user experience which includes a lot of prototyping of new solutions for user interfaces and user interaction.

While I have a background in C programming in a Linux environment, my daily work is mostly spent in Windows using C# and WPF.

Comments and Discussions