接上文,说说主框架。主框架作为一个宿主,提供整个应用程序的菜单及插件展示。
【.\SSHM.SmartClientOutput\ClientConfig\PlusMenu.xml】
<root>
<appMenu>
<plus text="关闭" tooltip="关闭系统"
type="CusFunc" img="./Images/Exit.png">
<dllPath>.\SSHM.PlusFunc\SSHM.PlusFunc.dlldllPath>
<clsName>SSHM.PlusFunc.FuncHelperclsName>
<funcName>CloseApplicationfuncName>
plus>
appMenu>
<quickAccess>
<plus text="关闭" tooltip="关闭系统"
type="CusFunc" img="./Images/Exit.png">
<dllPath>.\SSHM.PlusFunc\SSHM.PlusFunc.dlldllPath>
<clsName>SSHM.PlusFunc.FuncHelperclsName>
<funcName>CloseApplicationfuncName>
plus>
quickAccess>
<tab text="系统管理" tooltip="系统管理">
<group text="系统管理" tooltip="系统管理">
<plus text="插件管理" tooltip="插件管理"
type="UI" img="./Images/PlusIn.png">
<dllPath>.\SSHM.PlusMrg\SSHM.PlusMrg.dlldllPath>
<clsName>SSHM.PlusMrg.Views.UCPlusMainMrgclsName>
<position>DocumentHostposition>
plus>
<plus text="日志查看" tooltip="日志查看"
type="UI" img="./Images/Log.png">
<dllPath>.\SSHM.LogPlus\SSHM.LogPlus.dlldllPath>
<clsName>SSHM.LogPlus.Views.UCLogclsName>
<position>DockedBottomposition>
plus>
<plus text="主题切换" tooltip="主题切换"
type="UI" img="./Images/PlusIn.png">
<dllPath>.\SSHM.ThemingMrg\SSHM.ThemingMrg.dlldllPath>
<clsName>SSHM.ThemingMrg.Views.UCThemingMrgclsName>
<position>DockedTopposition>
plus>
<plus text="关闭" tooltip="关闭系统"
type="CusFunc" img="./Images/Exit.png">
<dllPath>.\SSHM.PlusFunc\SSHM.PlusFunc.dlldllPath>
<clsName>SSHM.PlusFunc.FuncHelperclsName>
<funcName>CloseApplicationfuncName>
plus>
group>
tab>
<tab text="小工具" tooltip="小工具">
<group text="系统工具" tooltip="系统工具">
<plus text="记事本" tooltip="记事本"
type="WinTool" img="./Images/Notepad.png">
<toolName>notepadtoolName>
plus>
<plus text="计算器" tooltip="计算器"
type="WinTool" img="./Images/Calc.png">
<toolName>calctoolName>
plus>
group>
tab>
root>
说明一下:
2.1、appMenu为开始菜单配置节点,下面可以配置多个插件,现在配置为
<appMenu>
<plus text="关闭" tooltip="关闭系统"
type="CusFunc" img="./Images/Exit.png">
<dllPath>.\SSHM.PlusFunc\SSHM.PlusFunc.dlldllPath>
<clsName>SSHM.PlusFunc.FuncHelperclsName>
<funcName>CloseApplicationfuncName>
plus>
appMenu>
只配置了一个关闭插件,点击该插件时,在主框架中调用动态库dllPath(.\SSHM.PlusFunc\SSHM.PlusFunc.dll)中类clsName(SSHM.PlusFunc.FuncHelper)的方法CloseApplication
2.2、工具栏菜单(quickAccess)同开始菜单一样,配置类似
2.3、tab组有系统管理和小工具
2.3.1、系统管理组有分了一个group(系统管理)组,有插件管理、日志查看、主题切换、关闭,前三个主框架会加载对应动态库的UI插件,显示在下面的工作区中,上一篇有图,关闭和开始菜单、工具栏菜单一样
2.3.2、小工具组分了一个系统工具组,框架会调用windows的记事本(notepad)、计算器(calc)等,配置都比较简单
<telerik:RadRibbonWindow x:Class="SSHM.SmartClient.Views.MainRibbonWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
xmlns:local="clr-namespace:SSHM.SmartClient.Views"
xmlns:com="clr-namespace:SSHM.SmartClient.Common"
telerik:StyleManager.Theme="{Binding ApplicationTheme}"
WindowState="Maximized"
Icon="{Binding AppConfig.SysIcon}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Closing">
<ei:CallMethodAction MethodName="RadRibbonWindow_Closing"
TargetObject="{Binding}"/>
i:EventTrigger>
i:Interaction.Triggers>
<telerik:RadBusyIndicator Grid.RowSpan="3" BusyContent="{Binding BusyContent}" IsBusy="{Binding IsBusy}">
<Grid Name="rootGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
Grid.RowDefinitions>
<Grid.Resources>
<DataTemplate x:Key="sysMenuTemplate">
<telerik:RadRibbonBackstageItem Header="{Binding Text}" IsSelectable="False" Icon="{Binding Image}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<ei:CallMethodAction MethodName="ExecuteMenuCommandHandler"
TargetObject="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadRibbonWindow},Path=DataContext}"/>
i:EventTrigger>
i:Interaction.Triggers>
telerik:RadRibbonBackstageItem>
DataTemplate>
<DataTemplate x:Key="ComMenuItemTemplate">
<telerik:RadRibbonButton Text="{Binding Text}"
ToolTip="{Binding ToolTip}"
SmallImage="{Binding Image}"
LargeImage="{Binding Image}"
Size="{Binding ButtonSize}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<ei:CallMethodAction MethodName="ExecuteMenuCommandHandler"
TargetObject="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadRibbonWindow},Path=DataContext}"/>
i:EventTrigger>
i:Interaction.Triggers>
telerik:RadRibbonButton>
DataTemplate>
<com:RibbonMenuItemTemplateSelector x:Key="GroupSelector" Buttons="{StaticResource ComMenuItemTemplate}"/>
<com:HierarchicalDataTemplate x:Key="GroupHeaderTemplate"
ItemsSource="{Binding ListItems}"
ItemTemplateSelector="{StaticResource ResourceKey=GroupSelector}">
<TextBlock Text="{Binding Text}"/>
com:HierarchicalDataTemplate>
<com:HierarchicalDataTemplate x:Key="TabTemplate"
ItemsSource="{Binding ListItems}"
ItemTemplate="{StaticResource ResourceKey=GroupHeaderTemplate}">
<TextBlock Text="{Binding Text}"/>
com:HierarchicalDataTemplate>
Grid.Resources>
<telerik:RadRibbonView x:Name="ribbonView"
HelpButtonVisibility="Visible"
ApplicationName="{Binding AppConfig.AppName}"
ItemsSource="{Binding PlusMenuViewModel.ListTabMenus}"
ItemTemplate="{StaticResource ResourceKey=TabTemplate}"
ApplicationButtonContent="{Binding AppConfig.AppMenuName}"
BackstageClippingElement="{Binding ElementName=rootGrid}"
Title="{Binding AppConfig.Title}"
IsBackstageOpen="{Binding IsBackstageOpen,Mode=TwoWay}"
SelectedItem="{Binding SelectedTab, Mode=TwoWay}"
HelpCommand="{Binding ShowHelperCmd}"
HelpCommandTarget="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadRibbonWindow},Path=DataContext}">
<telerik:RadRibbonView.Backstage>
<telerik:RadRibbonBackstage ItemTemplate="{StaticResource sysMenuTemplate}"
ItemsSource="{Binding PlusMenuViewModel.ListAppMenus}"/>
telerik:RadRibbonView.Backstage>
<telerik:RadRibbonView.QuickAccessToolBar>
<telerik:QuickAccessToolBar ItemTemplate="{StaticResource ComMenuItemTemplate}"
ItemsSource="{Binding PlusMenuViewModel.ListQuickAccessMenus}"/>
telerik:RadRibbonView.QuickAccessToolBar>
telerik:RadRibbonView>
<telerik:RadDocking x:Name="radDocking" Grid.Row="1">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Close" SourceName="radDocking">
<ei:CallMethodAction MethodName="RadDockingCloseCmdHandler" TargetObject="{Binding}"/>
i:EventTrigger>
<i:EventTrigger EventName="ActivePaneChanged" SourceName="radDocking">
<ei:CallMethodAction MethodName="RadDockingActivePaneChangedHandler" TargetObject="{Binding}"/>
i:EventTrigger>
i:Interaction.Triggers>
telerik:RadDocking>
<StatusBar Grid.Row="2">
<StatusBarItem Content="{Binding CurrentStatus}" HorizontalAlignment="Left"/>
<StatusBarItem Content="{Binding CurrentDatetime}" HorizontalAlignment="Right"/>
StatusBar>
Grid>
telerik:RadBusyIndicator>
telerik:RadRibbonWindow>
这段代码中,RadRibbonView负责加载菜单,RadDocking负责加载UI插件展示,StatusBar目前只有两个Item,自己加挺方便的
该xaml对应的ViewModel为SSHM.SmartClient\ViewModels\MainViewModel,该类负责加载配置文件,定义View层需要显示的菜单有状态栏属性等
发现写个简单的博客这么不容易,都不知道自己写的什么,如果看不懂,可以看看资源源码,感觉看源码要清晰明了的多