Hello. I'm trying to build a Silverlight application where I use 5 XAMLS. The first one, "Page.xaml" contains a menu with 4 buttons and a Canvas to receive the each content XAML. Each Content XAML has 2 storyboards: "entrada" (the "enter section" animation) and "saida" (the section ending animation).
I am experiencing the following problem: The menu is in Page.xaml. I want each button to, when clicked, begin the "saida" storyboard, and, when the storyboard finishes playing, it loads the new content of another XAML (picked by the menu). When I try to do it, Visual Studio keeps telling me that "'ContentCanvas' does not exist in the current context" for each content XAML.
Here is my Page.xaml.cs:
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace SilverlightPagingSystemProject
{
public partial class Page : UserControl
{
String secao = "home";
Section1 s1 = new Section1();
Section2 s2 = new Section2();
Section3 s3 = new Section3();
public Page()
{
// Required to initialize variables
InitializeComponent();
Link1.MouseLeftButtonDown += new MouseButtonEventHandler(Link1_MouseLeftButtonDown);
Link2.MouseLeftButtonDown += new MouseButtonEventHandler(Link2_MouseLeftButtonDown);
Link3.MouseLeftButtonDown += new MouseButtonEventHandler(Link3_MouseLeftButtonDown);
}
private void Link1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (secao == "home")
{
ContentCanvas.Children.Remove(s1);
ContentCanvas.Children.Remove(s2);
ContentCanvas.Children.Remove(s3);
ContentCanvas.Children.Add(s1);
}
else
{
ContentCanvas.saida.Begin();
}
}
private void Link2_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (secao == "home")
{
ContentCanvas.Children.Remove(s1);
ContentCanvas.Children.Remove(s2);
ContentCanvas.Children.Remove(s3);
ContentCanvas.Children.Add(s2);
}
else
{
ContentCanvas.saida.Begin();
}
}
private void Link3_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (secao == "home")
{
ContentCanvas.Children.Remove(s1);
ContentCanvas.Children.Remove(s2);
ContentCanvas.Children.Remove(s3);
ContentCanvas.Children.Add(s3);
}
else
{
ContentCanvas.saida.Begin();
}
}
}
}
And here is my sections XAML. All of them are the same.
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace SilverlightPagingSystemProject
{
public partial class Section3 : UserControl
{
public Section3()
{
// Required to initialize variables
InitializeComponent();
Section3LayoutRoot.Loaded += new RoutedEventHandler(Section1LayoutRoot_Loaded);
saida.Completed += new EventHandler(saida_Completed);
}
void saida_Completed(object sender, EventArgs e)
{
this.Parent.ContentCanvas.Children.Remove(s1);
this.Parent.ContentCanvas.Children.Remove(s2);
this.Parent.ContentCanvas.Children.Remove(s3);
this.Parent.ContentCanvas.Children.Add(secao);
}
void Section1LayoutRoot_Loaded(object sender, RoutedEventArgs e)
{
entrada.Begin();
}
}
}
Thanks for the help!