Silverlight版C1OutlookBar初体验

开发 前端 后端
ComponentOne 2011 v3版本中新增了Silverlight版本和WPF版本的c1OutlookBar控件。它对应的是WinForms版本的C1NavBar。因为“OutlookBar”更贴切也更准确,所以我们在XAML平台下使用了这个名字。有Outlook2007和2010样式。

ComponentOne 2011 v3版本中新增了Silverlight版本和WPF版本的c1OutlookBar控件。它对应的是WinForms版本的C1NavBar。因为“OutlookBar”更贴切也更准确,所以我们在XAML平台下使用了这个名字。有Outlook2007和2010样式。

 

clip_image002

 

OutlookBar类似一个TabControl,用户可以选择Content panel中的任何一个Item。你可以按照优先级为它们建立分类。OutlookBar可以通过拖拽操作,自由的收起或者展开各个项目。这样用户就可以方便的定制那些项目显示出来,哪些最小化到底部的菜单里。如图所示:

 

clip_image003

 

整个控件可以最小化到最左边或者最右边。当你不需要导航栏的时候,可以轻松的隐藏它,而将有限的屏幕空间用于显示其他UI。

C1OutlookBar支持14种不同的外观样式。其实基本上所有的ComponentOne Studio的控件都可以通过设置几个Brush属性来适应各种样式风格。这都要感谢ClearStyle技术。

 

clip_image005

 

控件结构

以一个最基本的例子来说,我们可以通过几行简单的XAML代码创建一个C1OutlookBar。每一个Item包含4个主要属性:Header,Content,LargeIcon以及SmallIcon。如下图所示:

 

clip_image007

 

此外,还需要指定哪些内容在控件收起的时候可以显示,这可以通过定义icon templates实现。下面的XAML代码是上图C1OutlookBar的全部代码:

  1. <c1:C1OutlookBar Name="c1OutlookBar1" ExpandedWidth="170" IsExpanded="True">   
  2.     <!-- content shown when the bar is collapsed -->   
  3.     <c1:C1OutlookBar.CollapsedContent>   
  4.         <c1:C1LayoutTransformer>   
  5.             <c1:C1LayoutTransformer.LayoutTransform>   
  6.                 <RotateTransform Angle="270" />   
  7.             </c1:C1LayoutTransformer.LayoutTransform>   
  8.             <TextBlock FontSize="13" TextAlignment="Center" VerticalAlignment="Center"   
  9.                         Text="Navigation Pane" />   
  10.         </c1:C1LayoutTransformer>   
  11.     </c1:C1OutlookBar.CollapsedContent>   
  12.     <!-- define icon templates -->   
  13.     <c1:C1OutlookBar.LargeIconTemplate>   
  14.         <DataTemplate>   
  15.             <Image Source="{Binding}" Width="24" Height="24" />   
  16.         </DataTemplate>   
  17.     </c1:C1OutlookBar.LargeIconTemplate>   
  18.     <c1:C1OutlookBar.SmallIconTemplate>   
  19.         <DataTemplate>   
  20.             <Grid Height="24">   
  21.                 <Image Source="{Binding}" Width="16" Height="16" />   
  22.             </Grid>   
  23.         </DataTemplate>   
  24.     </c1:C1OutlookBar.SmallIconTemplate>   
  25.     <!-- items -->   
  26.     <c1:C1OutlookItem Header="Home" SmallIcon="Images/16/Home.png" LargeIcon="Images/24/Home.png">   
  27.         <TextBlock Text="My Home" />   
  28.     </c1:C1OutlookItem>   
  29.     <c1:C1OutlookItem Header="Files" SmallIcon="Images/16/Cab1.png" LargeIcon="Images/24/Cab1.png">   
  30.         <TextBlock Text="My Files" />   
  31.     </c1:C1OutlookItem>   
  32.     <c1:C1OutlookItem Header="Sales" SmallIcon="Images/16/ChartPie.png" LargeIcon="Images/24/ChartPie.png">   
  33.         <TextBlock Text="My Sales" />   
  34.     </c1:C1OutlookItem>   
  35.     <c1:C1OutlookItem Header="History" SmallIcon="Images/16/History.png" LargeIcon="Images/24/History.png">   
  36.         <TextBlock Text="My History" />   
  37.     </c1:C1OutlookItem>   
  38.     <c1:C1OutlookItem Header="Settings" SmallIcon="Images/16/User.png" LargeIcon="Images/24/User.png">   
  39.         <TextBlock Text="My Settings" />   
  40.     </c1:C1OutlookItem>   
  41. </c1:C1OutlookBar> 

页面排布

当C1OutlookBar收起的时候,中间的content区域会自动展开,充满空余的界面。尤其是当把C1OutlookBar放在Grid中时,ColumnDefinition的宽度设置为Auto时,该功能支持的很好。同时初始化ExpandedWidth也很重要,当然了,这个属性可以在runtime修改。代码如下:

 

clip_image001

 

工作在MVVM模式下

C1OutlookBar是一个ItemsControl。我们可以将ItemsSource设置给一个由ViewModel定义的列表。这种用例下,我们还可以设置ItemTemplate,ContentTemplate。LargeIconTemplate以及SmallIconTemplate

原文:http://www.cnblogs.com/powertoolsteam/archive/2011/12/22/2297841.html

【编辑推荐】

  1. Silverlight***动态和未来前景
  2. 微软正式发布Silverlight 5
  3. 微软能否撑起Silverlight的明天?
  4. 基于Silverlight的网络操作系统SilveOS
  5. Silverlight企业应用开发实践之AgileEAS.NET
责任编辑:陈贻新 来源: 葡萄城控件技术团队博客
相关推荐

2010-05-13 21:03:42

Office 2010

2012-06-15 09:47:48

Objective-CCategory

2010-10-11 17:22:03

Ubuntu 10.1

2011-08-11 16:01:03

Objective-C面向对象内存

2012-07-11 14:34:50

OS X操作系统

2010-04-30 09:33:52

Ubuntu 10.0

2010-09-14 09:09:34

Debian GNUkFreebsd

2009-03-09 15:12:39

XenServer安装

2009-08-01 09:06:35

UbuntuOneLinux开源操作系统

2010-05-11 09:23:34

RHEL 6 Beta

2010-08-27 00:41:11

2023-07-15 08:01:38

2010-11-22 10:31:17

Sencha touc

2011-05-30 15:12:10

App Invento 初体验

2009-11-30 10:09:02

谷歌Chrome OS

2011-08-02 10:26:59

iOS 多线程 线程

2013-06-08 10:15:29

Outlook 201Outlook 201

2011-09-15 15:03:10

2010-12-13 11:39:39

2011-11-01 10:30:36

Node.js
点赞
收藏

51CTO技术栈公众号