首页 > Windows开发 > 详细

【WPF】 Prism 框架中,TabControl 作为Region时如何设置Header

时间:2021-06-06 21:13:23      阅读:14      评论:0      收藏:0      [点我收藏+]

MainWindow中:

 1  <Window.Resources>
 2         <Style TargetType="TabItem">
 3             <Setter Property="Header" Value="{Binding DataContext.Title}" />
 4         </Style>
 5     </Window.Resources>
 6     <StackPanel>
 7         <Button Content="Creat ViewA Page" />
 8         <Button Content="Creat ViewB Page" />
 9         <TabControl prism:RegionManager.RegionName="ContentRegion" />
10     </StackPanel>

主要是设置一个 “TabItem” 的样式 设置其Header 属性绑定为所属的ViewModel的 Title 属性。

ViewModel中:

 1 public class ViewAViewModel : BindableBase
 2     {
 3         private string _message;
 4         public string Message
 5         {
 6             get { return _message; }
 7             set { SetProperty(ref _message, value); }
 8         }
 9 
10         private string title;
11         public string Title
12         {
13             get { return title; }
14             set { SetProperty(ref title, value); }
15         }
16 
17         public ViewAViewModel()
18         {
19             Message = "View A from your Prism Module";
20             Title = "ViewA";
21         }
22     }

 

【WPF】 Prism 框架中,TabControl 作为Region时如何设置Header

原文:https://www.cnblogs.com/ganbei/p/14855906.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!