最开始是准备找像HTML的Fieldset的功能,可惜米有找到。如果只是外观像那样的话,其实自己做个控件,一个Textblock和rectangle就行了。随处乱找,找到这个控件,不管从界面布局上还是功能上都还不错,使用也很方便,特来分享一下。
不过这个是第三方控件,需要加Liquid.TreeView.dll的引用。
<UserControl x:Class="FieldSet.Page"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:liquidTreeView="clr-namespace:Liquid;assembly=Liquid.TreeView"
Width="400" Height="300">
<
Canvas
>
<
ScrollViewer Width
="204" Height
="250" Canvas.Left
="10" Canvas.Top
="145"
>
<
StackPanel Width
="204" Orientation
="Vertical"
>
<
liquidTreeView:FieldSet x:Name
="skills" Width
="174" HorizontalAlignment
="Left" IsExpanded
="True" Text
="Your Skills"
>
<
StackPanel
>
<
CheckBox x:Name
="aiprogrammer" Content
="A.I. Programmer" TabIndex
="4"
/>
<
CheckBox x:Name
="graphicsdesigner" Content
="Graphics Designer" TabIndex
="5"
/>
<
CheckBox x:Name
="systemsengineer" Content
="Systems Engineer" TabIndex
="6"
/>
<
CheckBox x:Name
="tester" Content
="Tester" TabIndex
="7"
/>
<
CheckBox x:Name
="webdeveloper" Content
="Web Developer" TabIndex
="8"
/>
<
/StackPanel
>
<
/liquidTreeView:FieldSet
>
<
liquidTreeView:FieldSet x:Name
="qualifications" Width
="174" IsEnabled
="False" HorizontalAlignment
="Left" IsExpanded
="False" Text
="Microsoft Qualifications"
>
<
StackPanel
>
<
CheckBox x:Name
="mcp" Content
="MCP" TabIndex
="10"
/>
<
CheckBox x:Name
="mvp" Content
="MVP" TabIndex
="11"
/>
<
CheckBox x:Name
="mcad" Content
="MCAD" TabIndex
="12"
/>
<
CheckBox x:Name
="mcsd" Content
="MCSD" TabIndex
="13"
/>
<
CheckBox x:Name
="otherQualification" Content
="Other" TabIndex
="14"
/>
<
/StackPanel
>
<
/liquidTreeView:FieldSet
>
<
liquidTreeView:FieldSet x:Name
="interests" Width
="174" HorizontalAlignment
="Left" IsExpanded
="False" Text
="Your Interests"
>
<
StackPanel
>
<
CheckBox x:Name
="cinema" Content
="Cinema" TabIndex
="10"
/>
<
CheckBox x:Name
="football" Content
="Football" TabIndex
="11"
/>
<
CheckBox x:Name
="holidaying" Content
="Holidaying" TabIndex
="12"
/>
<
CheckBox x:Name
="surfing" Content
="Surfing" TabIndex
="13"
/>
<
CheckBox x:Name
="tv" Content
="TV" TabIndex
="14"
/>
<
/StackPanel
>
<
/liquidTreeView:FieldSet
>
<
liquidTreeView:FieldSet x:Name
="years" Width
="174" HorizontalAlignment
="Left" IsExpanded
="False" Text
="Years experience?"
>
<
StackPanel
>
<
RadioButton x:Name
="sixmonths" Content
="Less Than 1 Year" Cursor
="Hand" TabIndex
="30" GroupName
="years"
/>
<
RadioButton x:Name
="twoyears" Content
="Between 1 and 2 Years" Cursor
="Hand" TabIndex
="32" GroupName
="years"
/>
<
RadioButton x:Name
="threeyears" Content
="More Than 2 Years" Cursor
="Hand" TabIndex
="33" GroupName
="years"
/>
<
/StackPanel
>
<
/liquidTreeView:FieldSet
>
<
/StackPanel
>
<
/ScrollViewer
>
<
/Canvas
>
<
/UserControl
>
CS:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace FieldSet
{
public
partial
class
Page :
UserControl
{
public
Page()
{
InitializeComponent();
}
}
}
效果如下:


点击下载:
Liquid.TreeView.dll
需要liquid的其他DLL的可以进去这个下载地址:
Liquid_5_3_2
liquid完整的demo进入这个下载地址:
Liquid Controls Souce
Controls Included:
Magnifier
ColorSelector
Dropdown
Table
Scroller
MainMenu
Menu
Viewer
TextRollerBlind
TextRotatorBlind
RichTextBlock
RollerBlind
ItemViewer
FlowPanel
RichTextBox
File/Data Uploader Component
Tree View
Collapsable Fieldset
Progress Bar
Popup Dialog
Popup Bubble
Popup MessageBox
Spell Checker Component
TextBlockPlus
NumericUpDown
ColorSelector
Dropdown
Table
Scroller
MainMenu
Menu
Viewer
TextRollerBlind
TextRotatorBlind
RichTextBlock
RollerBlind
ItemViewer
FlowPanel
RichTextBox
File/Data Uploader Component
Tree View
Collapsable Fieldset
Progress Bar
Popup Dialog
Popup Bubble
Popup MessageBox
Spell Checker Component
TextBlockPlus
NumericUpDown