在Silverlight 2 Beta2 中新加入了TabControl控件,使用它可以帮助我们实现属性页的效果。
如下图:
本DEMO的XAML代码段如下:
< Canvas x:name ="LayoutRoot" Background ="White" >< local:TabControl x:name ="tab1" Canvas.top ="20" Canvas.left ="20" Height ="100" WIDth ="300" />
< local:TabControl x:name ="tab2" Canvas.top ="140" Canvas.left ="20" Height ="100" WIDth ="300" />
< local:TabControl x:name ="tab3" Canvas.top ="280" Canvas.left ="20" Height ="100" WIDth ="300" >
< local:TabItem x:name ="white" header ="white" Background ="white" Style =" {StaticResource MyTabItemStyle} " />
< local:TabItem x:name ="red" header ="red" Background ="Red" Style =" {StaticResource MyTabItemStyle} " />
< local:TabItem x:name ="blue" header ="blue" Background ="Blue" Style =" {StaticResource MyTabItemStyle} " />
</ local:TabControl >
</ Canvas >
下面是它的page.xaml.cs代码:
public Page()
{
InitializeComponent();
this .Loaded += new RoutedEventHandler(Page_Loaded);
}
voID tab3_SelectionChanged( object sender, SelectionChangedEventArgs e)
{
tab3.Background = ((TabItem)tab3.SelectedItem).Background;
}
voID tab2_SelectionChanged( object sender, SelectionChangedEventArgs e)
{
tab1.Selectedindex = tab2.Selectedindex;
@H_512_301@// @H_512_301@object o = tab1.Findname("first item"); @H_512_301@
}
voID Page_Loaded( object sender, RoutedEventArgs e)
{
List < TabItem > tabItems = new List < TabItem > ()
{
new TabItem() {header = " 第一选项 " , Content = " 第一选项中内容 " },
new TabItem() {header = " 第二选项 " , Content = " 第二选项中内容 " },
new TabItem() {header = " 第三选项 " , Content = " 第三选项中内容 " }
};
foreach (TabItem tabItem in tabItems)
{
tab1.Items.Add(tabItem);
}
tabItems = new List < TabItem > ()
{
new TabItem() {header = " 第一选项 " , Content = " 第三选项中内容 " }
};
foreach (TabItem tabItem in tabItems)
{
tab2.Items.Add(tabItem);
}
tab1.TabStripPlacement = Dock.Bottom;
tab2.TabStripPlacement = Dock.left;
tab3.TabStripPlacement = Dock.top;
tab2.SelectionChanged += new SelectionChangedEventHandler(tab2_SelectionChanged);
tab3.SelectionChanged += new SelectionChangedEventHandler(tab3_SelectionChanged);
}
代码很简单,这里就不多说什么了。
源码下载链接,请点击这里:)
总结以上是内存溢出为你收集整理的在Silverlight 2 Beta2 中使用TabControl全部内容,希望文章能够帮你解决在Silverlight 2 Beta2 中使用TabControl所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)