【WPF】 Prism 框架中,TabControl 作为Region时如何设置Header
2021/6/6 18:20:54
本文主要是介绍【WPF】 Prism 框架中,TabControl 作为Region时如何设置Header,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
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的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-06-26小白家庭 nas 搭建方案-icode9专业技术文章分享
- 2024-06-23AI大模型企业应用实战(14)-langchain的Embedding
- 2024-06-23AI大模型企业应用实战(15)-langchain核心组件
- 2024-06-23AI大模型企业应用实战(16)-langchain核心组件
- 2024-06-23AI 大模型企业应用实战(06)-初识LangChain
- 2024-06-19EntBot.ai: AI Website Chatbot for Product Guides and Development Doc
- 2024-06-17zero-shot-learning-definition-examples-comparison
- 2024-06-06Package Easy(基于 NSIS 的打包exe安装包工具)使用方法-icode9专业技术文章分享
- 2024-06-06基于 casdoor 的 ELK 开源登录认证解决方案: elk-auth-casdoor-icode9专业技术文章分享
- 2024-05-29Elasticsearch慢查询日志配置