8,754
社区成员




<UserControl x:Class="SilverlightApplication1.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300"
>
<UserControl.Resources>
<StackPanel x:Name="myStackPanel" x:Key="mykey"/>
</UserControl.Resources>
<StackPanel x:Name="LayoutRoot" Background="White">
</StackPanel>
</UserControl>
//Code behind
public partial class Page : UserControl
{
System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
public Page()
{
InitializeComponent();
if(this.Resources.Contains("mykey"))
{
this.Resources.Remove("mykey");
}
LayoutRoot.Children.Add(myStackPanel);
myStackPanel.Children.Add(new Button { Content = "Hello World" });
}