1、 Silverlight: How to do navigation easily (Gill Cleeren)讲的是Silverlight 1.1中做页面导航
Here's a trick to a question I have heard a few times already: how to perform easy navigation in Silverlight 1.1?
我已经听过很多次关于如何在silverlight1.1中导航的技巧的问题? This problem can be partially solved using hidden panels: you click on a button, Panel1 is hidden and Panel2 becomes visible. This is a trick that is often done in ASP.net too.
这个问题可以用隐藏panels(翻译成面板?)的方式实现,点一下按钮,面板1隐藏,面板2显示。这个技巧也经常被用在ASP.net中。 Well, this trick can also be done in Silverlight, using the Control class. This class makes it possible to have a piece of XAML that has been loaded dynamically, act as a Control, that can be shown or hidden to do navigation (or actually, fake navigation).
ok,这个技巧也可以用在Silverlight中,使用控件类。这个类可以动态加载一个XAML作为控件,然后显示或者隐藏实现导航的效果(其实是假的导航)。 Consider the following code. I have a panel, Panel1, that inherits from Control. Inside the constructor, XAML is read from a resource (ie, a XAML file).
} Now, in the main code behind page, we'll instantiate the constructor of the Panel1 class, and we'll add the controls it generates dynamically (from the XAML that is) to the existing XAML.
在主页的后台代码中,实例化这个Panel1并动态添加到已存在的XAML中。
Panel1 p = new Panel1();
this.Children.Add(p);
//If we later want to remove the panel, the following line does the trick.