当前位置: 首页 > news >正文

微信的微网站是什么wordpress主题The7

微信的微网站是什么,wordpress主题The7,网站的运营,wordpress发文器WPF的基础控件详解 在WPF学习中 基本控件是最简单也是最基础的东西。也是很初学者容易忽略的 本此笔记教程主要针对WPF中基础控件使用和应用进行手把手教学#xff0c;如果学习了此笔记对你有帮助记得一键三连哦~~~~ TextBlock 基本用法 长字串处理 LineBreak标籤在指定的地…WPF的基础控件详解 在WPF学习中 基本控件是最简单也是最基础的东西。也是很初学者容易忽略的 本此笔记教程主要针对WPF中基础控件使用和应用进行手把手教学如果学习了此笔记对你有帮助记得一键三连哦~~~~ TextBlock 基本用法 长字串处理 LineBreak标籤在指定的地方手动换行。TextTrimming属性并设为**CharacterEllipsis**让TextBlock在没有足够空间的时候显示…。在没有足够空间显示这麽多文字时这是一种常见的方法。这也很适合用在当空间不足而且你不想使用多行的时候。你也可以使用**CharacterEllipsis**的另一种**WordEllipsis**当空间不足的时候以最后一个单字为单位显示就不会有单字只显示一部分的问题发生。TextWrapping 属性并设为**Wrap**让TextBlock在没有足够空间显示时自动换行。 TextBlock内联格式 粗体(Bold), 斜体(Italic), 下划线(Underline) 超连接 (Hyperlink) Span块的使用 C# 或逻辑代码格式化文本 TextBlock tb new TextBlock(); tb.TextWrapping TextWrapping.Wrap; tb.Margin new Thickness(10); tb.Inlines.Add(An example on ); tb.Inlines.Add(new Run(the TextBlock control ) { FontWeight FontWeights.Bold }); tb.Inlines.Add(using ); tb.Inlines.Add(new Run(inline ) { FontStyle FontStyles.Italic }); tb.Inlines.Add(new Run(text formatting ) { Foreground Brushes.Blue }); tb.Inlines.Add(from ); tb.Inlines.Add(new Run(Code-Behind) { TextDecorations TextDecorations.Underline }); tb.Inlines.Add(.); this.Content tb; Label Label和访问键(助记符) StackPanel Margin10Label Content_Name: Target{Binding ElementNametxtName} /TextBox NametxtName /Label Content_Mail: Target{Binding ElementNametxtMail} /TextBox NametxtMail / /StackPanel 使用控件作为Label的内容 Label Target{Binding ElementNametxtName}StackPanel OrientationHorizontalImage Sourcehttp://cdn1.iconfinder.com/data/icons/fatcow/16/bullet_green.png /AccessText Text_Name: //StackPanel /Label TextBox NametxtName / Label Target{Binding ElementNametxtMail}StackPanel OrientationHorizontalImage Sourcehttp://cdn1.iconfinder.com/data/icons/fatcow/16/bullet_blue.png /AccessText Text_Mail: //StackPanel /Label TextBox NametxtMail / Label控件和TextBlock控件的对比 那为什么要使用Label呢 好吧Label和TextBlock之间有一些重要的区别。 TextBlock仅允许您呈现文本字串而Label还允许您做下列的事情 设定边界(border)渲染其他控件例如一张图片通过ContentTemplate属性使用模板化的内容使用访问键聚焦到相关的控件上 最后一个点是使用Label取代TextBlock控件的其中一个主要原因.当你只是需要渲染简单的文本内容时,你应该使用TextBlock控件,因为它更轻量并且在大多数场景下性能比Label好. TextBox 单行TextBox 多行文本框 有拼写检查的TextBox SpellCheck类中名为IsEnabled的附加属性该属性仅支持对父控件进行拼写检查以及Language属性该属性指示拼写检查器使用的语言。 使用TextBox的选择属性 DockPanel Margin10TextBox SelectionChangedTextBox_SelectionChanged DockPanel.DockTop /TextBox NametxtStatus AcceptsReturnTrue TextWrappingWrap IsReadOnlyTrue / /DockPanel 选择事件 private void TextBox_SelectionChanged(object sender, RoutedEventArgs e) {TextBox textBox sender as TextBox;txtStatus.Text Selection starts at character # textBox.SelectionStart Environment.NewLine;txtStatus.Text Selection is textBox.SelectionLength character(s) long Environment.NewLine;txtStatus.Text Selected text: textBox.SelectedText ; } 我们使用三个相关的属性来实现 SelectionStart它给出了当前光标位置或是否有选择它从什么位置开始。 SelectionLength它给出了当前选择的长度如果有的话。 否则它将返回0。 SelectedText如果有选择它会给我们当前选择的字符串。 否则返回一个空字符串。 Button 简单的按钮 格式化内容 具有高级内容的按钮 ButtonStackPanel OrientationHorizontalTextBlockFormatted /TextBlockTextBlock ForegroundBlue FontWeightBold Margin2,0Button/TextBlockTextBlock ForegroundGray FontStyleItalic[Various]/TextBlock/StackPanel /Button 带图片的按钮ImageButton Button Padding5 StackPanel OrientationHorizontal Image Source/WpfTutorialSamples;component/Images/help.png / TextBlock Margin5,0Help/TextBlock /StackPanel /Button 按钮填充 Button Padding5,2Hello, World!/Button基于通用样式编写 Window.ResourcesStyle TargetType{x:Type Button}Setter PropertyPadding Value5,2//Style /Window.Resources CheckBox 基本内容 自定义内容 IsThreeState 属性 IsThreeState 的一般用法是创建一个“全部启用”的 CheckBox让它控制一系列的子 CheckBox并显示它们作为一个整体的状态。我们下面的例子展示了如何创建几个可开关的功能并在窗口最上面有一个“全部启用”的 CheckBox StackPanel Margin10Label FontWeightBoldApplication Options/LabelStackPanel Margin10,5CheckBox IsThreeStateTrue NamecbAllFeatures CheckedcbAllFeatures_CheckedChanged UncheckedcbAllFeatures_CheckedChangedEnable all/CheckBoxStackPanel Margin20,5CheckBox NamecbFeatureAbc CheckedcbFeature_CheckedChanged UncheckedcbFeature_CheckedChangedEnable feature ABC/CheckBoxCheckBox NamecbFeatureXyz IsCheckedTrue CheckedcbFeature_CheckedChanged UncheckedcbFeature_CheckedChangedEnable feature XYZ/CheckBoxCheckBox NamecbFeatureWww CheckedcbFeature_CheckedChanged UncheckedcbFeature_CheckedChangedEnable feature WWW/CheckBox/StackPanel/StackPanel /StackPanel private void cbAllFeatures_CheckedChanged(object sender, RoutedEventArgs e) {bool newVal (cbAllFeatures.IsChecked true);cbFeatureAbc.IsChecked newVal;cbFeatureXyz.IsChecked newVal;cbFeatureWww.IsChecked newVal; } private void cbFeature_CheckedChanged(object sender, RoutedEventArgs e) {cbAllFeatures.IsChecked null;if((cbFeatureAbc.IsChecked true) (cbFeatureXyz.IsChecked true) (cbFeatureWww.IsChecked true))cbAllFeatures.IsChecked true;if((cbFeatureAbc.IsChecked false) (cbFeatureXyz.IsChecked false) (cbFeatureWww.IsChecked false))cbAllFeatures.IsChecked false; } RadioButton 基本用法 RadioButton 组 GroupNameready 自定义内容 StackPanel Margin10Label FontWeightBoldAre you ready?/LabelRadioButtonWrapPanelImage Source/WpfTutorialSamples;component/Images/accept.png Width16 Height16 Margin0,0,5,0 /TextBlock TextYes ForegroundGreen //WrapPanel/RadioButtonRadioButton Margin0,5WrapPanelImage Source/WpfTutorialSamples;component/Images/cancel.png Width16 Height16 Margin0,0,5,0 /TextBlock TextNo ForegroundRed //WrapPanel/RadioButtonRadioButton IsCheckedTrueWrapPanelImage Source/WpfTutorialSamples;component/Images/question.png Width16 Height16 Margin0,0,5,0 /TextBlock TextMaybe ForegroundGray //WrapPanel/RadioButton /StackPanel PasswordBox 基本用法PasswordChar Image Source属性 动态加载图片后置代码 StackPanelWrapPanel Margin10 HorizontalAlignmentCenterButton NamebtnLoadFromFile Margin0,0,20,0 ClickBtnLoadFromFile_ClickLoad from File.../ButtonButton NamebtnLoadFromResource ClickBtnLoadFromResource_ClickLoad from Resource/Button/WrapPanelImage NameimgDynamic Margin10 / /StackPanel private void BtnLoadFromFile_Click(object sender, RoutedEventArgs e) {OpenFileDialog openFileDialog new OpenFileDialog();if(openFileDialog.ShowDialog() true){Uri fileUri new Uri(openFileDialog.FileName);imgDynamic.Source new BitmapImage(fileUri);} }private void BtnLoadFromResource_Click(object sender, RoutedEventArgs e) {Uri resourceUri new Uri(/Images/white_bengal_tiger.jpg, UriKind.Relative);imgDynamic.Source new BitmapImage(resourceUri); } Stretch属性 Uniform: 这是默认模式。 图片将自动缩放以便它适合图片区域。 将保留图片的宽高比。UniformToFill: 图片将被缩放以便完全填充图片区域。 将保留图片的宽高比。Fill: 图片将缩放以适合图片控件的区域。 可能无法保留宽高比因为图片的高度和宽度是独立缩放的。None: 如果图片小于图片控件则不执行任何操作。 如果它比图片控件大则会裁剪图片以适合图片控件这意味着只有部分图片可见。 GridGrid.ColumnDefinitionsColumnDefinition Width* /ColumnDefinition Width* /ColumnDefinition Width* /ColumnDefinition Width* //Grid.ColumnDefinitionsGrid.RowDefinitionsRowDefinition HeightAuto /RowDefinition Height* //Grid.RowDefinitionsLabel Grid.Column0 HorizontalAlignmentCenter FontWeightBoldUniform/LabelLabel Grid.Column1 HorizontalAlignmentCenter FontWeightBoldUniformToFill/LabelLabel Grid.Column2 HorizontalAlignmentCenter FontWeightBoldFill/LabelLabel Grid.Column3 HorizontalAlignmentCenter FontWeightBoldNone/LabelImage Source/Images/white_bengal_tiger.jpg StretchUniform Grid.Column0 Grid.Row1 Margin5 /Image Source/Images/white_bengal_tiger.jpg StretchUniformToFill Grid.Column1 Grid.Row1 Margin5 /Image Source/Images/white_bengal_tiger.jpg StretchFill Grid.Column2 Grid.Row1 Margin5 /Image Source/Images/white_bengal_tiger.jpg StretchNone Grid.Column3 Grid.Row1 Margin5 / /Grid ToolTip 基础用法 Grid VerticalAlignmentCenter HorizontalAlignmentCenterButton ToolTipClick here and something will happen!Click here!/Button /Grid 应用 DockPanelToolBar DockPanel.DockTopButton ToolTipCreate a new fileButton.ContentImage Source/WpfTutorialSamples;component/Images/page_white.png Width16 Height16 //Button.Content/ButtonButtonButton.ContentImage Source/WpfTutorialSamples;component/Images/folder.png Width16 Height16 //Button.ContentButton.ToolTipStackPanelTextBlock FontWeightBold FontSize14 Margin0,0,0,5Open file/TextBlockTextBlockSearch your computer or local networkLineBreak /for a file and open it for editing./TextBlockBorder BorderBrushSilver BorderThickness0,1,0,0 Margin0,8 /WrapPanelImage Source/WpfTutorialSamples;component/Images/help.png Margin0,0,5,0 /TextBlock FontStyleItalicPress F1 for more help/TextBlock/WrapPanel/StackPanel/Button.ToolTip/Button/ToolBarTextBoxEditor area.../TextBox /DockPanel 高级选项ShowDuration ShowDuration 属性扩展工具提示的时间我们将其设置为5.000毫秒或5秒 WPF文本渲染 控制文本渲染TextFormattingMode StackPanel Margin10Label TextOptions.TextFormattingModeIdeal FontSize9TextFormattingMode.Ideal, small text/LabelLabel TextOptions.TextFormattingModeDisplay FontSize9TextFormattingMode.Display, small text/LabelLabel TextOptions.TextFormattingModeIdeal FontSize20TextFormattingMode.Ideal, large text/LabelLabel TextOptions.TextFormattingModeDisplay FontSize20TextFormattingMode.Display, large text/Label /StackPanel TextRenderingMode StackPanel Margin10 TextOptions.TextFormattingModeDisplayLabel TextOptions.TextRenderingModeAuto FontSize9TextRenderingMode.Auto, small text/LabelLabel TextOptions.TextRenderingModeAliased FontSize9TextRenderingMode.Aliased, small text/LabelLabel TextOptions.TextRenderingModeClearType FontSize9TextRenderingMode.ClearType, small text/LabelLabel TextOptions.TextRenderingModeGrayscale FontSize9TextRenderingMode.Grayscale, small text/LabelLabel TextOptions.TextRenderingModeAuto FontSize18TextRenderingMode.Auto, large text/LabelLabel TextOptions.TextRenderingModeAliased FontSize18TextRenderingMode.Aliased, large text/LabelLabel TextOptions.TextRenderingModeClearType FontSize18TextRenderingMode.ClearType, large text/LabelLabel TextOptions.TextRenderingModeGrayscale FontSize18TextRenderingMode.Grayscale, large text/Label /StackPanel Tab顺序 TabIndex和**IsTabStop**。 TabIndex用于定义顺序而IsTabStop将强制WPF在窗口按Tab时跳过这个控件。 Grid Margin20Grid.ColumnDefinitionsColumnDefinition Width* /ColumnDefinition Width20 /ColumnDefinition Width* //Grid.ColumnDefinitionsGrid.RowDefinitionsRowDefinition Height* /RowDefinition HeightAuto //Grid.RowDefinitionsStackPanelLabelFirst name:/LabelTextBox /LabelStreet name:/LabelTextBox /LabelCity:/LabelTextBox IsReadOnlyTrue IsTabStopFalse BackgroundLightYellow //StackPanelStackPanel Grid.Column2LabelLast name:/LabelTextBox /LabelZip Code:/LabelTextBox //StackPanelButton Grid.Row1 HorizontalAlignmentRight Width80Add/ButtonButton Grid.Row1 Grid.Column2 HorizontalAlignmentLeft Width80Cancel/Button /Grid Border 基础用法 圆角边界 Grid Margin10Border BackgroundGhostWhite BorderBrushSilver BorderThickness1 CornerRadius8,8,3,3StackPanel Margin10ButtonButton 1/ButtonButton Margin0,10Button 2/ButtonButtonButton 3/Button/StackPanel/Border /Grid 边界颜色/宽度 Grid Margin10Border BackgroundGhostWhite BorderBrushDodgerBlue BorderThickness1,3,1,5StackPanel Margin10ButtonButton 1/ButtonButton Margin0,10Button 2/ButtonButtonButton 3/Button/StackPanel/Border /Grid 边界背景 Grid Margin10Border BorderBrushNavy BorderThickness1,3,1,5Border.BackgroundLinearGradientBrush StartPoint0.5,0 EndPoint0.5,1GradientStop ColorLightCyan Offset0.0 /GradientStop ColorLightBlue Offset0.5 /GradientStop ColorDarkTurquoise Offset1.0 //LinearGradientBrush/Border.BackgroundStackPanel Margin10ButtonButton 1/ButtonButton Margin0,10Button 2/ButtonButtonButton 3/Button/StackPanel/Border /Grid Slider 基本用法 刻度 StackPanel VerticalAlignmentCenter Margin10Slider Maximum100 TickPlacementBottomRight TickFrequency5 / /StackPanel 捕获标记 StackPanel VerticalAlignmentCenter Margin10Slider Maximum100 TickPlacementBottomRight TickFrequency10 IsSnapToTickEnabledTrue / /StackPanel Slider值 DockPanel VerticalAlignmentCenter Margin10TextBox Text{Binding ElementNameslValue, PathValue, UpdateSourceTriggerPropertyChanged} DockPanel.DockRight TextAlignmentRight Width40 /Slider Maximum255 TickPlacementBottomRight TickFrequency5 IsSnapToTickEnabledTrue NameslValue / /DockPanel 响应变化的值 StackPanel Margin10 VerticalAlignmentCenterDockPanel VerticalAlignmentCenter Margin10Label DockPanel.DockLeft FontWeightBoldR:/LabelTextBox Text{Binding ElementNameslColorR, PathValue, UpdateSourceTriggerPropertyChanged} DockPanel.DockRight TextAlignmentRight Width40 /Slider Maximum255 TickPlacementBottomRight TickFrequency5 IsSnapToTickEnabledTrue NameslColorR ValueChangedColorSlider_ValueChanged //DockPanelDockPanel VerticalAlignmentCenter Margin10Label DockPanel.DockLeft FontWeightBoldG:/LabelTextBox Text{Binding ElementNameslColorG, PathValue, UpdateSourceTriggerPropertyChanged} DockPanel.DockRight TextAlignmentRight Width40 /Slider Maximum255 TickPlacementBottomRight TickFrequency5 IsSnapToTickEnabledTrue NameslColorG ValueChangedColorSlider_ValueChanged //DockPanelDockPanel VerticalAlignmentCenter Margin10Label DockPanel.DockLeft FontWeightBoldB:/LabelTextBox Text{Binding ElementNameslColorB, PathValue, UpdateSourceTriggerPropertyChanged} DockPanel.DockRight TextAlignmentRight Width40 /Slider Maximum255 TickPlacementBottomRight TickFrequency5 IsSnapToTickEnabledTrue NameslColorB ValueChangedColorSlider_ValueChanged //DockPanel /StackPanel private void ColorSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgsdouble e) {Color color Color.FromRgb((byte)slColorR.Value, (byte)slColorG.Value, (byte)slColorB.Value);this.Background new SolidColorBrush(color); } ProgressBar 基本操作 在执行漫长的任务时显示进度 Grid Margin20ProgressBar Minimum0 Maximum100 NamepbStatus / /Grid private void Window_ContentRendered(object sender, EventArgs e) {for(int i 0; i 100; i){pbStatus.Value;Thread.Sleep(100);} } BackgroundWorker private void Window_ContentRendered(object sender, EventArgs e) {BackgroundWorker worker new BackgroundWorker();worker.WorkerReportsProgress true;worker.DoWork worker_DoWork;worker.ProgressChanged worker_ProgressChanged;worker.RunWorkerAsync(); } void worker_DoWork(object sender, DoWorkEventArgs e) {for(int i 0; i 100; i){(sender as BackgroundWorker).ReportProgress(i);Thread.Sleep(100);} } void worker_ProgressChanged(object sender, ProgressChangedEventArgs e) {pbStatus.Value e.ProgressPercentage; } 不确定 Grid Margin20ProgressBar Minimum0 Maximum100 NamepbStatus IsIndeterminateTrue / /Grid ProgressBar显示文本 Grid Margin20ProgressBar Minimum0 Maximum100 Value75 NamepbStatus /TextBlock Text{Binding ElementNamepbStatus, PathValue, StringFormat{}{0:0}%} HorizontalAlignmentCenter VerticalAlignmentCenter / /Grid WebBrowser Window.CommandBindingsCommandBinding CommandNavigationCommands.BrowseBack CanExecuteBrowseBack_CanExecute ExecutedBrowseBack_Executed /CommandBinding CommandNavigationCommands.BrowseForward CanExecuteBrowseForward_CanExecute ExecutedBrowseForward_Executed /CommandBinding CommandNavigationCommands.GoToPage CanExecuteGoToPage_CanExecute ExecutedGoToPage_Executed / /Window.CommandBindings DockPanelToolBar DockPanel.DockTopButton CommandNavigationCommands.BrowseBackImage Source/WpfTutorialSamples;component/Images/arrow_left.png Width16 Height16 //ButtonButton CommandNavigationCommands.BrowseForwardImage Source/WpfTutorialSamples;component/Images/arrow_right.png Width16 Height16 //ButtonSeparator /TextBox NametxtUrl Width300 KeyUptxtUrl_KeyUp /Button CommandNavigationCommands.GoToPageImage Source/WpfTutorialSamples;component/Images/world_go.png Width16 Height16 //Button/ToolBarWebBrowser NamewbSample NavigatingwbSample_Navigating/WebBrowser /DockPanel public partial class WebBrowserControlSample : Window {public WebBrowserControlSample(){InitializeComponent();wbSample.Navigate(http://www.wpf-tutorial.com);}private void txtUrl_KeyUp(object sender, KeyEventArgs e){if(e.Key Key.Enter)wbSample.Navigate(txtUrl.Text);}private void wbSample_Navigating(object sender, System.Windows.Navigation.NavigatingCancelEventArgs e){txtUrl.Text e.Uri.OriginalString;}private void BrowseBack_CanExecute(object sender, CanExecuteRoutedEventArgs e){e.CanExecute ((wbSample ! null) (wbSample.CanGoBack));}private void BrowseBack_Executed(object sender, ExecutedRoutedEventArgs e){wbSample.GoBack();}private void BrowseForward_CanExecute(object sender, CanExecuteRoutedEventArgs e){e.CanExecute ((wbSample ! null) (wbSample.CanGoForward));}private void BrowseForward_Executed(object sender, ExecutedRoutedEventArgs e){wbSample.GoForward();}private void GoToPage_CanExecute(object sender, CanExecuteRoutedEventArgs e){e.CanExecute true;}private void GoToPage_Executed(object sender, ExecutedRoutedEventArgs e){wbSample.Navigate(txtUrl.Text);} } WindowsFromsHost 使用WinForms WebBrowser控件 GridWindowsFormsHost NamewfhSampleWindowsFormsHost.Childwf:WebBrowser DocumentTitleChangedwbWinForms_DocumentTitleChanged //WindowsFormsHost.Child/WindowsFormsHost /Grid public partial class WindowsFormsHostSample : Window {public WindowsFormsHostSample(){InitializeComponent();(wfhSample.Child as System.Windows.Forms.WebBrowser).Navigate(http://www.wpf-tutorial.com);}private void wbWinForms_DocumentTitleChanged(object sender, EventArgs e){this.Title (sender as System.Windows.Forms.WebBrowser).DocumentTitle;} } 组合框 基本用法 GridGroupBox HeaderGroupBox Sample Margin10 Padding10StackPanelTextBlockFirst name:/TextBlockTextBox /TextBlockLast name:/TextBlockTextBox /Button Margin0,20Add User/Button/StackPanel/GroupBox /Grid 自定义标题组合框 GridGroupBox Margin10 Padding10GroupBox.HeaderStackPanel OrientationHorizontalImage Source/WpfTutorialSamples;component/Images/group.png Margin3,0 /TextBlock FontWeightBoldGroupBox Sample/TextBlock/StackPanel/GroupBox.HeaderStackPanelTextBlockFirst name:/TextBlockTextBox /TextBlockLast name:/TextBlockTextBox /Button Margin0,20Add User/Button/StackPanel/GroupBox /Grid 注意我这里用**GroupBox.Header**标记简单替换了Header属性随后添加了一个StackPanel 以便包含一个 Image 和一个 TextBlock —— 这样一来你就能对 Header 完全自定义了 日历控件 基本用法 GridCalendar / /Grid 日历大小 ViewboxCalendar / /ViewboxViewbox StretchFill StretchDirectionUpOnlyCalendar / /Viewbox DisplayDate设置初始化视图 ViewboxCalendar DisplayDate01.01.2014 / /Viewbox Calendar 选中模式 ViewboxCalendar SelectionModeSingleRange /Calendar SelectionModeMultipleRange / /Viewbox 选中日期 StackPanel Margin10Calendar NamecldSample SelectionModeMultipleRange SelectedDate10.10.2013 /LabelSelected date:/LabelTextBox Text{Binding ElementNamecldSample, PathSelectedDate, StringFormatd, UpdateSourceTriggerPropertyChanged} / /StackPanel public CalendarSelectionSample() {InitializeComponent();cldSample.SelectedDate DateTime.Now.AddDays(1); } 多选日期 StackPanel Margin10Calendar NamecldSample SelectionModeMultipleRange /LabelSelected dates:/LabelListBox ItemsSource{Binding ElementNamecldSample, PathSelectedDates} MinHeight150 / /StackPanel 删除日期 ViewboxCalendar NamecldSample SelectionModeMultipleRangeCalendar.BlackoutDatesCalendarDateRange Start10.13.2013 End10.19.2013 /CalendarDateRange Start10.27.2013 End10.31.2013 //Calendar.BlackoutDates/Calendar /Viewbox public CalendarBlockedoutDatesSample() {InitializeComponent();cldSample.BlackoutDates.AddDatesInPast();cldSample.BlackoutDates.Add(new CalendarDateRange(DateTime.Today, DateTime.Today.AddDays(1))); } 显示模式-显示月份或者年份 DisplayMode属性能够将Calendar 控件从一个你能选中一个日期的位置更改为到你能够选中一个月甚至一年的位置这是能通过DisplayMode 做到该属性默认为月份我们已经在之前的例子中都使用到了 ViewboxCalendar DisplayModeYear / /Viewbox DisplayMode [Year, Decade] 日历选择器 基本用法 添加一个DatePicker 控件 StackPanel Margin20LabelName:/LabelTextBox /LabelBirthday:/LabelDatePicker/DatePickerLabelGender:/LabelComboBoxComboBoxItemFemale/ComboBoxItemComboBoxItemMale/ComboBoxItem/ComboBoxButton Margin20Signup/Button /StackPanel 显示日期和选择日期 DatePicker SelectedDate2000-12-31/DatePicker DatePicker Namedp1 DisplayDate2019-01-01 / 选择日期格式 DatePicker SelectedDate2000-12-31 SelectedDateFormatLong/DatePicker排除日期 DatePicker Namedp1DatePicker.BlackoutDatesCalendarDateRange Start2019-04-01 End2019-04-07 /CalendarDateRange Start2019-04-22 End2019-04-28 //DatePicker.BlackoutDates /DatePicker 扩展控件 它的代码当然非常简单 Expander TextBlock TextWrappingWrap FontSize18 Here we can have text which can be hidden/shown using the built-in functionality of the Expander control. /TextBlock /Expander Expander 默认是不会扩展开来的所以就想第一张截图所看到那样。用户可以通过点击它扩展或者你能让它通过**IsExpanded** 属性初始时扩展 Expander IsExpandedTrue你当然也能在运行时读到这个属性如果你需要知道关于Expander 的当前状态。 高级内容 Expander Margin10StackPanel Margin10DockPanelImage Source/WpfTutorialSamples;component/Images/question32.png Width32 Height32 DockPanel.DockRight Margin10/ImageTextBlock TextWrappingWrap FontSize18Did you know that WPF is really awesome? Just enter your e-mail address below and well send you updates:/TextBlock/DockPanelTextBox Margin10johndoe.org/TextBox/StackPanel /Expander 扩展方向 Expander Margin10 ExpandDirectionRightTextBlock TextWrappingWrap FontSize18Here we can have text which can be hidden/shown using the built-in functionality of the Expander control./TextBlock /Expander 自定义标题 Expander Margin10 HeaderClick to show/hide content...TextBlock TextWrappingWrap FontSize18Here we can have text which can be hidden/shown using the built-in functionality of the Expander control./TextBlock /Expander Header属性允许你去添加控件进去去创建一个更加定制的外观 Expander Margin10Expander.HeaderDockPanel VerticalAlignmentStretchImage Source/WpfTutorialSamples;component/Images/bullet_green.png Height16 DockPanel.DockLeft /TextBlock FontStyleItalic ForegroundGreenClick to show/hide content.../TextBlock/DockPanel/Expander.HeaderTextBlock TextWrappingWrap FontSize18Here we can have text which can be hidden/shown using the built-in functionality of the Expander control./TextBlock /Expander ItemsControl 一个简单的ItemsControl范例 Grid Margin10ItemsControlsystem:StringItemsControl Item #1/system:Stringsystem:StringItemsControl Item #2/system:Stringsystem:StringItemsControl Item #3/system:Stringsystem:StringItemsControl Item #4/system:Stringsystem:StringItemsControl Item #5/system:String/ItemsControl /Grid 有数据绑定的ItemsControl Grid Margin10ItemsControl NameicTodoListItemsControl.ItemTemplateDataTemplateGrid Margin0,0,0,5Grid.ColumnDefinitionsColumnDefinition Width* /ColumnDefinition Width100 //Grid.ColumnDefinitionsTextBlock Text{Binding Title} /ProgressBar Grid.Column1 Minimum0 Maximum100 Value{Binding Completion} //Grid/DataTemplate/ItemsControl.ItemTemplate/ItemsControl /Grid public partial class ItemsControlDataBindingSample : Window {public ItemsControlDataBindingSample(){InitializeComponent();ListTodoItem items new ListTodoItem();items.Add(new TodoItem() { Title Complete this WPF tutorial, Completion 45 });items.Add(new TodoItem() { Title Learn C#, Completion 80 });items.Add(new TodoItem() { Title Wash the car, Completion 0 });icTodoList.ItemsSource items;} }public class TodoItem {public string Title { get; set; }public int Completion { get; set; } } ItemsPanelTemplate属性 Grid Margin10ItemsControlItemsControl.ItemsPanelItemsPanelTemplateWrapPanel //ItemsPanelTemplate/ItemsControl.ItemsPanelItemsControl.ItemTemplateDataTemplateButton Content{Binding} Margin0,0,5,5 //DataTemplate/ItemsControl.ItemTemplatesystem:StringItem #1/system:Stringsystem:StringItem #2/system:Stringsystem:StringItem #3/system:Stringsystem:StringItem #4/system:Stringsystem:StringItem #5/system:String/ItemsControl /Grid UniformGrid面板我们可以在其中定义多个列然后将我们的项目整齐地显示在同样宽 Grid Margin10ScrollViewer VerticalScrollBarVisibilityAuto HorizontalScrollBarVisibilityAutoItemsControlsystem:StringItemsControl Item #1/system:Stringsystem:StringItemsControl Item #2/system:Stringsystem:StringItemsControl Item #3/system:Stringsystem:StringItemsControl Item #4/system:Stringsystem:StringItemsControl Item #5/system:String/ItemsControl/ScrollViewer /Grid ListBox 基本用法 Grid Margin10ListBoxListBoxItemListBox Item #1/ListBoxItemListBoxItemListBox Item #2/ListBoxItemListBoxItemListBox Item #3/ListBoxItem/ListBox /Grid ListBox数据绑定 Grid Margin10ListBox NamelbTodoList HorizontalContentAlignmentStretchListBox.ItemTemplateDataTemplateGrid Margin0,2Grid.ColumnDefinitionsColumnDefinition Width* /ColumnDefinition Width100 //Grid.ColumnDefinitionsTextBlock Text{Binding Title} /ProgressBar Grid.Column1 Minimum0 Maximum100 Value{Binding Completion} //Grid/DataTemplate/ListBox.ItemTemplate/ListBox /Grid public partial class ListBoxDataBindingSample : Window {public ListBoxDataBindingSample(){InitializeComponent();ListTodoItem items new ListTodoItem();items.Add(new TodoItem() { Title Complete this WPF tutorial, Completion 45 });items.Add(new TodoItem() { Title Learn C#, Completion 80 });items.Add(new TodoItem() { Title Wash the car, Completion 0 });lbTodoList.ItemsSource items;} } public class TodoItem {public string Title { get; set; }public int Completion { get; set; } } ListBox选择 DockPanel Margin10StackPanel DockPanel.DockRight Margin10,0StackPanel.ResourcesStyle TargetTypeButtonSetter PropertyMargin Value0,0,0,5 //Style/StackPanel.ResourcesTextBlock FontWeightBold Margin0,0,0,10ListBox selection/TextBlockButton NamebtnShowSelectedItem ClickbtnShowSelectedItem_ClickShow selected/ButtonButton NamebtnSelectLast ClickbtnSelectLast_ClickSelect last/ButtonButton NamebtnSelectNext ClickbtnSelectNext_ClickSelect next/ButtonButton NamebtnSelectCSharp ClickbtnSelectCSharp_ClickSelect C#/ButtonButton NamebtnSelectAll ClickbtnSelectAll_ClickSelect all/Button/StackPanelListBox NamelbTodoList HorizontalContentAlignmentStretch SelectionModeExtended SelectionChangedlbTodoList_SelectionChangedListBox.ItemTemplateDataTemplateGrid Margin0,2Grid.ColumnDefinitionsColumnDefinition Width* /ColumnDefinition Width100 //Grid.ColumnDefinitionsTextBlock Text{Binding Title} /ProgressBar Grid.Column1 Minimum0 Maximum100 Value{Binding Completion} //Grid/DataTemplate/ListBox.ItemTemplate/ListBox /DockPanel public partial class ListBoxSelectionSample : Window {public ListBoxSelectionSample(){InitializeComponent();ListTodoItem items new ListTodoItem();items.Add(new TodoItem() { Title Complete this WPF tutorial, Completion 45 });items.Add(new TodoItem() { Title Learn C#, Completion 80 });items.Add(new TodoItem() { Title Wash the car, Completion 0 });lbTodoList.ItemsSource items;}private void lbTodoList_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e){if(lbTodoList.SelectedItem ! null)this.Title (lbTodoList.SelectedItem as TodoItem).Title;}private void btnShowSelectedItem_Click(object sender, RoutedEventArgs e){foreach(object o in lbTodoList.SelectedItems)MessageBox.Show((o as TodoItem).Title);}private void btnSelectLast_Click(object sender, RoutedEventArgs e){lbTodoList.SelectedIndex lbTodoList.Items.Count - 1;}private void btnSelectNext_Click(object sender, RoutedEventArgs e){int nextIndex 0;if((lbTodoList.SelectedIndex 0) (lbTodoList.SelectedIndex (lbTodoList.Items.Count - 1)))nextIndex lbTodoList.SelectedIndex 1;lbTodoList.SelectedIndex nextIndex;}private void btnSelectCSharp_Click(object sender, RoutedEventArgs e){foreach(object o in lbTodoList.Items){if((o is TodoItem) ((o as TodoItem).Title.Contains(C#))){lbTodoList.SelectedItem o;break;}}}private void btnSelectAll_Click(object sender, RoutedEventArgs e){foreach(object o in lbTodoList.Items)lbTodoList.SelectedItems.Add(o);} } public class TodoItem {public string Title { get; set; }public int Completion { get; set; } } ComboBox 基本用法 StackPanel Margin10ComboBoxComboBoxItemComboBox Item #1/ComboBoxItemComboBoxItem IsSelectedTrueComboBox Item #2/ComboBoxItemComboBoxItemComboBox Item #3/ComboBoxItem/ComboBox /StackPanel 自定义内容 StackPanel Margin10ComboBoxComboBoxItemStackPanel OrientationHorizontalImage Source/WpfTutorialSamples;component/Images/bullet_red.png /TextBlock ForegroundRedRed/TextBlock/StackPanel/ComboBoxItemComboBoxItemStackPanel OrientationHorizontalImage Source/WpfTutorialSamples;component/Images/bullet_green.png /TextBlock ForegroundGreenGreen/TextBlock/StackPanel/ComboBoxItemComboBoxItemStackPanel OrientationHorizontalImage Source/WpfTutorialSamples;component/Images/bullet_blue.png /TextBlock ForegroundBlueBlue/TextBlock/StackPanel/ComboBoxItem/ComboBox /StackPanel 数据绑定ComboBox StackPanel Margin10ComboBox NamecmbColorsComboBox.ItemTemplateDataTemplateStackPanel OrientationHorizontalRectangle Fill{Binding Name} Width16 Height16 Margin0,2,5,2 /TextBlock Text{Binding Name} //StackPanel/DataTemplate/ComboBox.ItemTemplate/ComboBox /StackPanel public partial class ComboBoxDataBindingSample : Window {public ComboBoxDataBindingSample(){InitializeComponent();cmbColors.ItemsSource typeof(Colors).GetProperties();} } IsEditable StackPanel Margin10ComboBox IsEditableTrueComboBoxItemComboBox Item #1/ComboBoxItemComboBoxItemComboBox Item #2/ComboBoxItemComboBoxItemComboBox Item #3/ComboBoxItem/ComboBox /StackPanel 使用ComboBox选择 StackPanel Margin10ComboBox NamecmbColors SelectionChangedcmbColors_SelectionChangedComboBox.ItemTemplateDataTemplateStackPanel OrientationHorizontalRectangle Fill{Binding Name} Width16 Height16 Margin0,2,5,2 /TextBlock Text{Binding Name} //StackPanel/DataTemplate/ComboBox.ItemTemplate/ComboBoxWrapPanel Margin15 HorizontalAlignmentCenterButton NamebtnPrevious ClickbtnPrevious_Click Width55Previous/ButtonButton NamebtnNext ClickbtnNext_Click Margin5,0 Width55Next/ButtonButton NamebtnBlue ClickbtnBlue_Click Width55Blue/Button/WrapPanel /StackPanel public partial class ComboBoxSelectionSample : Window {public ComboBoxSelectionSample(){InitializeComponent();cmbColors.ItemsSource typeof(Colors).GetProperties();}private void btnPrevious_Click(object sender, RoutedEventArgs e){if(cmbColors.SelectedIndex 0)cmbColors.SelectedIndex cmbColors.SelectedIndex - 1;}private void btnNext_Click(object sender, RoutedEventArgs e){if(cmbColors.SelectedIndex cmbColors.Items.Count-1)cmbColors.SelectedIndex cmbColors.SelectedIndex 1;}private void btnBlue_Click(object sender, RoutedEventArgs e){cmbColors.SelectedItem typeof(Colors).GetProperty(Blue);}private void cmbColors_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e){Color selectedColor (Color)(cmbColors.SelectedItem as PropertyInfo).GetValue(null, null);this.Background new SolidColorBrush(selectedColor);} }
文章转载自:
http://www.morning.nlkm.cn.gov.cn.nlkm.cn
http://www.morning.mpbgy.cn.gov.cn.mpbgy.cn
http://www.morning.qbrs.cn.gov.cn.qbrs.cn
http://www.morning.rqknq.cn.gov.cn.rqknq.cn
http://www.morning.rnzgf.cn.gov.cn.rnzgf.cn
http://www.morning.lynb.cn.gov.cn.lynb.cn
http://www.morning.pgkpt.cn.gov.cn.pgkpt.cn
http://www.morning.frqtc.cn.gov.cn.frqtc.cn
http://www.morning.mmzfl.cn.gov.cn.mmzfl.cn
http://www.morning.jnzfs.cn.gov.cn.jnzfs.cn
http://www.morning.chxsn.cn.gov.cn.chxsn.cn
http://www.morning.yqyhr.cn.gov.cn.yqyhr.cn
http://www.morning.wnkbf.cn.gov.cn.wnkbf.cn
http://www.morning.qhmhz.cn.gov.cn.qhmhz.cn
http://www.morning.mltsc.cn.gov.cn.mltsc.cn
http://www.morning.wbllx.cn.gov.cn.wbllx.cn
http://www.morning.dygqq.cn.gov.cn.dygqq.cn
http://www.morning.qwrb.cn.gov.cn.qwrb.cn
http://www.morning.lhzqn.cn.gov.cn.lhzqn.cn
http://www.morning.rscrj.cn.gov.cn.rscrj.cn
http://www.morning.gfprf.cn.gov.cn.gfprf.cn
http://www.morning.qngcq.cn.gov.cn.qngcq.cn
http://www.morning.sqnxk.cn.gov.cn.sqnxk.cn
http://www.morning.bfrsr.cn.gov.cn.bfrsr.cn
http://www.morning.dqrhz.cn.gov.cn.dqrhz.cn
http://www.morning.smpmn.cn.gov.cn.smpmn.cn
http://www.morning.cfpq.cn.gov.cn.cfpq.cn
http://www.morning.mlnbd.cn.gov.cn.mlnbd.cn
http://www.morning.xuejitest.com.gov.cn.xuejitest.com
http://www.morning.gzxnj.cn.gov.cn.gzxnj.cn
http://www.morning.ysrtj.cn.gov.cn.ysrtj.cn
http://www.morning.tnzwm.cn.gov.cn.tnzwm.cn
http://www.morning.qnbzs.cn.gov.cn.qnbzs.cn
http://www.morning.hwbmn.cn.gov.cn.hwbmn.cn
http://www.morning.nbybb.cn.gov.cn.nbybb.cn
http://www.morning.rdtq.cn.gov.cn.rdtq.cn
http://www.morning.ldzss.cn.gov.cn.ldzss.cn
http://www.morning.rtmqy.cn.gov.cn.rtmqy.cn
http://www.morning.htqrh.cn.gov.cn.htqrh.cn
http://www.morning.bkgfp.cn.gov.cn.bkgfp.cn
http://www.morning.fdmfn.cn.gov.cn.fdmfn.cn
http://www.morning.jjwt.cn.gov.cn.jjwt.cn
http://www.morning.mzqhb.cn.gov.cn.mzqhb.cn
http://www.morning.hffpy.cn.gov.cn.hffpy.cn
http://www.morning.rtsx.cn.gov.cn.rtsx.cn
http://www.morning.gzxnj.cn.gov.cn.gzxnj.cn
http://www.morning.lbxhy.cn.gov.cn.lbxhy.cn
http://www.morning.qpmwb.cn.gov.cn.qpmwb.cn
http://www.morning.bxqpl.cn.gov.cn.bxqpl.cn
http://www.morning.gfhng.cn.gov.cn.gfhng.cn
http://www.morning.dhdzz.cn.gov.cn.dhdzz.cn
http://www.morning.gbhsz.cn.gov.cn.gbhsz.cn
http://www.morning.yqtry.cn.gov.cn.yqtry.cn
http://www.morning.jbfzx.cn.gov.cn.jbfzx.cn
http://www.morning.grbgn.cn.gov.cn.grbgn.cn
http://www.morning.cwyfs.cn.gov.cn.cwyfs.cn
http://www.morning.w58hje.cn.gov.cn.w58hje.cn
http://www.morning.tbbxn.cn.gov.cn.tbbxn.cn
http://www.morning.tdxlj.cn.gov.cn.tdxlj.cn
http://www.morning.rhkmn.cn.gov.cn.rhkmn.cn
http://www.morning.nlysd.cn.gov.cn.nlysd.cn
http://www.morning.mzbyl.cn.gov.cn.mzbyl.cn
http://www.morning.dhqg.cn.gov.cn.dhqg.cn
http://www.morning.rqqct.cn.gov.cn.rqqct.cn
http://www.morning.djxnn.cn.gov.cn.djxnn.cn
http://www.morning.mzcsp.cn.gov.cn.mzcsp.cn
http://www.morning.qxwwg.cn.gov.cn.qxwwg.cn
http://www.morning.wlfxn.cn.gov.cn.wlfxn.cn
http://www.morning.mnkz.cn.gov.cn.mnkz.cn
http://www.morning.mkyxp.cn.gov.cn.mkyxp.cn
http://www.morning.daidudu.com.gov.cn.daidudu.com
http://www.morning.dfqmy.cn.gov.cn.dfqmy.cn
http://www.morning.newfeiya.com.cn.gov.cn.newfeiya.com.cn
http://www.morning.fykrm.cn.gov.cn.fykrm.cn
http://www.morning.wrtw.cn.gov.cn.wrtw.cn
http://www.morning.tsmcc.cn.gov.cn.tsmcc.cn
http://www.morning.hpjpy.cn.gov.cn.hpjpy.cn
http://www.morning.mkrqh.cn.gov.cn.mkrqh.cn
http://www.morning.tmjhy.cn.gov.cn.tmjhy.cn
http://www.morning.tckxl.cn.gov.cn.tckxl.cn
http://www.tj-hxxt.cn/news/268739.html

相关文章:

  • 小学生做网站软件恩施网站建设模板
  • 山东省建设教育集团网站成都购房登记入口官网
  • 深圳网站制作哪家好薇专业做网站平台
  • 招标网站哪个好用久久网招聘信息
  • 网站开发和app开发哪个难青岛建设集团
  • 商丘做网站用什么程序比较好WordPress播放h265
  • 体检中心 网站建设方案哪个视频网站做视频赚钱的
  • 义乌市评建设职称网站网站建设常熟
  • 家政服务网站模板如何做公司网站的
  • 湖南网站建设 干净磐石网络python和php做网站
  • 共享vps可以做网站吗铁岭网站建设
  • 北京工地网站建设新云网站模版
  • 做巧克力的网站做中小型网站最好的架构
  • 网站建设管理制度九不准英雄联盟网页设计代码
  • 上海网站推广优化公司郑州网络营销哪个好
  • 如何制作学校网站制作网站品牌公司
  • 池州做网站培训个人网站的设计与实现
  • 可以制作h5的网站网站建设的特点
  • 北京单页营销型网站制作网站建设迁移方案
  • 平湖新埭哪里有做网站的用网站模板做新网站
  • 贵州企业网站如何做一个网址
  • 高质量视频素材网站石景山网站制作案例
  • 怎样保证网站的安全襄阳购物网站开发设计
  • 淘宝店铺网站策划书m 外贸网站
  • 做展厅 参考什么网站建筑培训网站
  • 网站开发项目报价wordpress如何进数据库
  • dw制作网站网站开发外包公司合同
  • 简述网站开发平台及常用工具牛商网做网站要多少钱
  • asp网站显示建设中专业的网站制作
  • 宁波市住房和城乡建设厅网站wordpress数据库重置