0

我想将两个用户控件放入选项卡控件中,但只有当我单击一个按钮时,用户控件才会加载数据

<Button Click="Button_Click_1" />
<Button Click="Button_Click_2" />
<TabControl>
    <ItemsControl Name="tab1">
        <local:UserControl1 Loaded="UserControl1_Loaded"></local:UserControl1>
    </ItemsControl>
    <ItemsControl Name="tab2">
         <local:UserControl1 Loaded="UserControl2_Loaded"></local:UserControl1>
    </ItemsControl>
</TabControl>
4

1 回答 1

0
private class  TabSource 
{
   private string dataForTab = string.empty; 
   public string DataForTab { get { return dataForTab; } } 
   public void GetRealData()
   {
      dataForTab = "Real Data";
      NotifyPropertyChanged("DataForTab");
   }
}


public Button_Click_2(...)
{
    MyTabSource.GetRealData();       
}
于 2012-11-01T19:11:03.217 回答