简体   繁体   English

将用户控件加载到tabcontrol中

[英]Load usercontrol into tabcontrol

I want to put two usercontrols into the tabcontrol, but only when I click on a button the usercontrol will load the data 我想将两个usercontrol放入tabcontrol,但是只有当我单击按钮时,usercontrol才会加载数据

<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>
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();       
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM