惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
N
News and Events Feed by Topic
D
DataBreaches.Net
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Engineering at Meta
Engineering at Meta
T
Tailwind CSS Blog
博客园_首页
Microsoft Azure Blog
Microsoft Azure Blog
Y
Y Combinator Blog
博客园 - Franky
Hugging Face - Blog
Hugging Face - Blog
月光博客
月光博客
A
About on SuperTechFans
I
InfoQ
S
Securelist
Last Week in AI
Last Week in AI
S
Schneier on Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
Hacker News: Ask HN
Hacker News: Ask HN
Schneier on Security
Schneier on Security
Know Your Adversary
Know Your Adversary
腾讯CDC
大猫的无限游戏
大猫的无限游戏
S
Security @ Cisco Blogs
博客园 - 三生石上(FineUI控件)
Simon Willison's Weblog
Simon Willison's Weblog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Tor Project blog
美团技术团队
aimingoo的专栏
aimingoo的专栏
G
Google Developers Blog
罗磊的独立博客
Vercel News
Vercel News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Cloudflare Blog
S
Secure Thoughts
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Latest news
Latest news
Recent Announcements
Recent Announcements
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
L
LINUX DO - 热门话题
Security Latest
Security Latest
TaoSecurity Blog
TaoSecurity Blog
Cyberwarzone
Cyberwarzone
有赞技术团队
有赞技术团队

博客园 - kuning的程序博客

第一章 第二课 Using Resources Cmd,powershell 参考 百度WSUS 我也转关于软件测试的文章 了解WMI 英文面试题 据说是微软面试哦 算法 之 万年历 算法 之 哥德巴赫猜想 - kuning的程序博客 C# 理论学习 之 面向对象设计 C# 理论学习 之 类、组,名称空间 C# 深入学习 之 Winform记录日志 C#深入学习 之 委托和事件 C#数据结构-排序之快速排序法 .Net本地化资源 PHP之安装篇 Sql Server中的行列互换 再叙2005Web控件(一) - kuning的程序博客 - 博客园 Poket PC 与 sqlserver2000(以上) RDA 方案
第一章 第一课 Using WPF Control
kuning的程序博客 · 2011-05-31 · via 博客园 - kuning的程序博客

■ Explain what a content control is.
■ Describe and use several common WPF controls.
■ Use a dependency property.
■ Create and use an item control in your user interface.
■ Create a menu.
■ Create a toolbar.
■ Create a status bar.
■ Explain the properties of a control that manage layout.
■ Explain how to use the Grid control.
■ Explain how to use the UniformGrid control.
■ Explain how to use the StackPanel control.
■ Explain how to use the WrapPanel control.
■ Explain how to use the DockPanel control.
■ Explain how to use the Canvas control.
■ Configure control sizing.
■ Align content at design time.
■ Use the GridSplitter control.

WPF Control 

Individual controls

Item control

layout controls

一、Content controls: Lable, button,checkbox,radiobutton
  • 1) derives from the ContentControl and has Content property
  • 2) The type of the Content property is Object, so it can accept any object as content. How
    content is rendered, however, depends on the type of the object in the Content property
  • For items that do not derive from UIElement, the ToString method is called, and the resulting
    string is rendered as the control content. Items that derive from UIElement, however, are
    displayed as contained within the content control
  • 3) content controls can contain only a single nested element there is no inherent limit on the number of nested elements that the content can contain

View Co

// Summary:
// Represents the base class for all System.Windows.Controls.Button controls.
[DefaultEvent("Click")]
[Localizability(LocalizationCategory.Button)]
public abstract class ButtonBase : ContentControl, ICommandSource // Summary:// Represents a control with a single piece of content of any type.[ContentProperty("Content")][Localizability(LocalizationCategory.None, Readability = Readability.Unreadable)][DefaultProperty("Content")]public class ContentControl : Control, IAddChild{ // Summary: // Identifies the System.Windows.Controls.ContentControl.Content dependency // property. // // Returns: // The identifier for the System.Windows.Controls.ContentControl.Content dependency // property. [CommonDependencyProperty] public static readonly DependencyProperty ContentProperty; // // Summary: // Identifies the System.Windows.Controls.ContentControl.ContentStringFormat // dependency property. // // Returns: // The identifier for the System.Windows.Controls.ContentControl.ContentStringFormat // dependency property. [CommonDependencyProperty] public static readonly DependencyProperty ContentStringFormatProperty; // // Summary: // Identifies the System.Windows.Controls.ContentControl.ContentTemplate dependency // property. // // Returns: // The identifier for the System.Windows.Controls.ContentControl.ContentTemplate dependency // property. [CommonDependencyProperty] public static readonly DependencyProperty ContentTemplateProperty; // // Summary: // Identifies the System.Windows.Controls.ContentControl.ContentTemplateSelector dependency // property. // // Returns: // The identifier for the System.Windows.Controls.ContentControl.ContentTemplateSelector dependency // property. [CommonDependencyProperty] public static readonly DependencyProperty ContentTemplateSelectorProperty; // // Summary: // Identifies the System.Windows.Controls.ContentControl.HasContent dependency // property. // // Returns: // The identifier for the System.Windows.Controls.ContentControl.HasContent dependency // property. [CommonDependencyProperty] public static readonly DependencyProperty HasContentProperty;// Summary:// Initializes a new instance of the System.Windows.Controls.ContentControl// class.[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]public ContentControl();// Summary:// Gets or sets the content of a System.Windows.Controls.ContentControl.//// Returns:// An object that contains the control's content. The default value is null.[Bindable(true)][CustomCategory("Content")]public object Content { get; set; }//// Summary:// Gets or sets a composite string that specifies how to format the System.Windows.Controls.ContentControl.Content// property if it is displayed as a string.//// Returns:// A composite string that specifies how to format the System.Windows.Controls.ContentControl.Content// property if it is displayed as a string.[Bindable(true)][CustomCategory("Content")]public string ContentStringFormat { get; set; }//// Summary:// Gets or sets the data template used to display the content of the System.Windows.Controls.ContentControl.//// Returns:// A data template. The default value is null.[Bindable(true)][CustomCategory("Content")]public DataTemplate ContentTemplate { get; set; }//// Summary:// Gets or sets a template selector that enables an application writer to provide// custom template-selection logic.//// Returns:// A data template selector. The default value is null.[CustomCategory("Content")][Bindable(true)][DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]public DataTemplateSelector ContentTemplateSelector { get; set; }//// Summary:// Gets a value that indicates whether the System.Windows.Controls.ContentControl// contains content.//// Returns:// true if the System.Windows.Controls.ContentControl has content; otherwise// false. The default value is false.[ReadOnly(true)][Browsable(false)]public bool HasContent { get; }//// Summary:// Gets an enumerator to the content control's logical child elements.//// Returns:// An enumerator. The default value is null.protected internal override IEnumerator LogicalChildren { get; }

    二、Label Control and Mnemonic Keys
    Labels contain built-in support for mnemonic keys, which move the focus to a designated
    control
    when the Alt key is pressed with the mnemonic key.

The mnemonic key is specified by preceding the ddesired key with the underscore (_) symbol and appears underlined at run time when the Alt
key is pressed. we can designate a target control by setting the Target property of the Label control

Sample code:

<Label Name="Label1"  Width="100" Target="{Binding ElementName=testBox1}">Press Alt+_A</Label>
<TextBox Name="testBox1" Height="26" Width="100" ></TextBox>

When user press Alt+A, The input focus will move to textbox.

三、Button Control

IsDefault property and the IsCancel property  

1) default property

When IsDefault is set to True, the button’s Click event is raised
ou press Enter

2)IsCancel property

When IsCancel is set to True, the button’s Click event is raised
when Esc is pressed.

3)ACCESS KEYS:

the button will be clicked when the user presses Alt and that key together

<Button>_Click Me!</Button>

RADIOBUTTON CONTROL

You can have multiple groups in a single container by setting the GroupName property

<RadioButton GroupName="Group1" Name="RadioButton1" Height="22" VerticalAlignment="Top" Margin="15,10,0,0" HorizontalAlignment="Left" Width="76">Button 1</RadioButton>
<RadioButton GroupName="Group1" Name="RadioButton2" Margin="15,34,0,0" Height="22" VerticalAlignment="Top" HorizontalAlignment="Left" Width="76">Button 2</RadioButton>
<RadioButton GroupName="Group2" Name="RadioButton3" Margin="15,58,0,0" Height="21" HorizontalAlignment="Left" VerticalAlignment="Top" Width="76">Button 3</RadioButton>
<RadioButton GroupName="Group2" Name="RadioButton4" Margin="15,85,0,0" Height="22" HorizontalAlignment="Left" VerticalAlignment="Top" Width="76">Button 4</RadioButton>

==

<StackPanel Height="29" VerticalAlignment="Top">
<RadioButton Name="RadioButton1">Button 1</RadioButton>
<RadioButton Name="RadioButton2">Button 2</RadioButton>
</StackPanel>
<StackPanel Height="34" Margin="0,34,0,0" VerticalAlignment="Top">
<RadioButton Name="RadioButton3">Button 3</RadioButton>
<RadioButton Name="RadioButton4">Button 4</RadioButton>
</StackPanel>

CHECKBOX CONTROL

The IsChecked property is a Boolean? (bool? in C#) data type similar to the Boolean type but allows an indeterminate state as well. A check
box will be in the indeterminate state when a window first opens.

Other control:

TextBlock

Image:

Scretch: None, Fill, Uniform, UniformFill

None: 图片原始尺寸

Fill:适应ImageControl大小

Uniform:等比缩放适应ImageControl,ImageControl不一定被填满,但图片不会被剪切

UniformFill:等比缩放,并填充ImageControl。图片可能会被剪切

Progressbar

Textbox

Slider bar

Setting the Tab Order for Controls

By default, controls in the user interface will receive the focus
from Tab key presses in the order in which they are defined in the XAML

TabIndex

KeyboardNavigation.IsTabStop="False" to keep a control from receiving focus when the user presses the Tab key

Item Controls

ListBox

<ListBox Name="listbox1" VerticalAlignment="Top">
<CheckBox Name="Chk1">Option 1</CheckBox>
<CheckBox Name="Chk2">Option 2</CheckBox>
<CheckBox Name="Chk3">Option 3</CheckBox>
<CheckBox Name="Chk4">Option 4</CheckBox>
</ListBox>

<TreeView>
<TreeViewItem Header="Pizza Toppings">
<CheckBox Content="Pepperoni"/>
<CheckBox Content="Sausage"/>
<CheckBox Content="Mushroom"/>
<CheckBox Content="Tomato"/>
Lesson 1: Using WPF Controls CHAPTER 1 15
</TreeViewItem>
<TreeViewItem Header="Sandwich Items">
<CheckBox Content="Lettuce"/>
<CheckBox Content="Tomato"/>
<CheckBox Content="Mustard"/>
<CheckBox Content="Hot Peppers"/>
</TreeViewItem>
</TreeView>

<Menu Height="22" Name="menu1" VerticalAlignment="Top"
HorizontalAlignment="Left" Width="278">
<MenuItem Header="_File">
<MenuItem Header="Open"/>
<MenuItem Header="Close"/>
<MenuItem Header="Save" Command="ApplicationCommands.Save"/>
</MenuItem>
</Menu>

<TextBox>
<TextBox.ContextMenu>
<ContextMenu>
<MenuItem Header="Cut" Command="ApplicationCommands.Cut"/>
<MenuItem Header="Copy" Command="ApplicationCommands.Copy"/>
<MenuItem Header="Paste" Command="ApplicationCommands.Paste"/>
</ContextMenu>
</TextBox.ContextMenu>
</TextBox>

<ToolBarTray Name="toolBarTray1" Height="65" VerticalAlignment="Top">
<ToolBar Name="toolBar1" Height="26" VerticalAlignment="Top">
<Button>Back</Button>
<Button>Forward</Button>
<Button>Stop</Button>
</ToolBar>
<ToolBar>
<TextBox Width="100"/>
<Button>Go</Button>
</ToolBar>
</ToolBarTray>
 
Layout Controls