做ppt网站,无锡门户网站制作服务,网站开发后端有哪些,网络优化工程师工资由于园子里昨天使用Live Writer上传出现问题#xff0c;昨天只能使用Web上的文本编辑器上传本文#xff0c;造成代码、内容等格式的错误#xff0c;现重发本文。 一、Panel内容模型 Panel内容模型指从System.Windows.Controls.Panel继承的控件#xff0c;这些控件都是容器昨天只能使用Web上的文本编辑器上传本文造成代码、内容等格式的错误现重发本文。 一、Panel内容模型 Panel内容模型指从System.Windows.Controls.Panel继承的控件这些控件都是容器可以在内部承载其他的控件和子容器。Panel内容模型包含的容器有 Canvas DockPanel Grid TabPanel ToolBarOverflowPanel UniformGrid StackPanel ToolBarPanel VirtualizingPanel VirtualizingStackPanel WrapPanel 对于Panel模型其包含一个Children属性表示其所有的子控件和子容器的集合在XAML代码中可以省略XXX.Children标记如 1: StackPanel x:NamemainPanel 2: StackPanel x:NamepanelA 3: StackPanel.Children 4: ButtonButton A/Button 5: /StackPanel.Children 6: /StackPanel 7: ButtonButton B/Button 8: StackPanel x:NamepanelB 9: /StackPanel 10: /StackPanel 也可以通过代码动态添加Children中的对象 1: // 定义一个Button 2: Button btn new Button(); 3: btn.Content Button C; 4: 5: // 将Button添加到StackPanel中 6: panelB.Children.Add(btn); 二、Decorator内容模型 Decorator内容模型指的是从System.Windows.Controls.Decorator类继承的控件主要是对其中的一个子元素的边缘进行修饰。Decorator模型的主要控件包含 AdornerDecorator Border BulletDecorator ButtonChrome ClassicBorderDecorator InkPresenter ListBoxChrome SystemDropShadowChrome Viewbox Decorator模型包含一个Child属性表示其包含的一个子元素注意只能是一个子元素控件或容器在容器中可以再添加其他的控件Child属性的XAML标记可以省略。 例如对于一个TextBox添加一个边框使用XAML语言定义 1: StackPanel x:NamemainPanel 2: Border BorderThickness5 BorderBrushDarkBlue Margin5 3: Border.Child 4: TextBox TextTextBox Content/ 5: /Border.Child 6: /Border 7: /StackPanel 也可以使用代码完成上述功能 1: // 定义一个Border对象并设置其边框的大小颜色外边距 2: Border border new Border(); 3: border.BorderThickness new Thickness(5); 4: border.BorderBrush new SolidColorBrush(Colors.DarkRed); 5: border.Margin new Thickness(5); 6: 7: // 定义一个TextBox对象 8: TextBox textBox new TextBox(); 9: textBox.Text TextBox Content Text; 10: 11: // 使用Border修饰TextBox的边框 12: border.Child textBox; 13: 14: // 将Border添加到StackPanel中 15: mainPanel.Children.Add(border); 三、TextBlock模型 TextBlock模型实际上指的就是System.Windows.Controls.TextBlock类它是一个用于显示少量流内容的轻量控件。其中包含一个InLines属性支持 Inline 流内容元素的承载和显示。 支持的元素包括 AnchoredBlock、Bold粗体字符串、Hyperlink超链接在浏览器支持的模式下有效、InlineUIContainer承载其他控件的容器、Italic斜体字符串、LineBreak换行符、Run普通字符串、Span可以设置字体、颜色等的Span 和 Underline下划线。 例如 1: StackPanel OrientationHorizontal 2: Border BorderThickness2 Margin5 BorderBrushBlack 3: TextBlock Margin5 TextWrappingWrapWithOverflow 4: TextBlock.Inlines 5: Bold 6: RunBlockText 控件XAML示例/Run 7: /Bold 8: LineBreak/ 9: RunTextBlock支持以下的几种流显示样式/Run 10: LineBreak/ 11: Bold粗体Bold/Bold 12: LineBreak/ 13: Italic斜体Italic/Italic 14: LineBreak/ 15: Underline下划线Underline/Underline 16: LineBreak/ 17: Hyperlink NavigateUrihttp://www.microsoft.com超链接/Hyperlink 18: LineBreak/ 19: Span ForegroundRed FontSize18Span设置字体、颜色等/Span 20: LineBreak / 21: InlineUIContainer 22: StackPanel BackgroundAntiqueWhite Margin5 23: TextBlockInline UI 容器/TextBlock 24: Button Content按钮 Width80 / 25: /StackPanel 26: /InlineUIContainer 27: /TextBlock.Inlines 28: /TextBlock 29: /Border 30: Border BorderThickness2 Margin5 BorderBrushBlack 31: TextBlock Margin5 TextWrappingWrapWithOverflow x:NametextBlock 32: TextBlock.Inlines 33: Bold 34: Run x:Nametitle/Run 35: /Bold 36: LineBreak x:Nameline/ 37: InlineUIContainer x:Namecontainer 38: StackPanel BackgroundAntiqueWhite Margin5 x:Namepanel 39: /StackPanel 40: /InlineUIContainer 41: /TextBlock.Inlines 42: /TextBlock 43: /Border 44: /StackPanel 使用代码操作Inlines 1: // 设置Inline对象的属性值 2: title.Text TextBlock 控件代码示例; 3: 4: // 添加Inline对象 5: Run content new Run(TextBlock支持以下的几种流显示样式); 6: Bold bold new Bold(new Run(粗体)); 7: Italic italic new Italic(new Run(斜体)); 8: Underline underline new Underline(new Run(下划线)); 9: Hyperlink hyperlink new Hyperlink(new Run(超链接)); 10: hyperlink.NavigateUri new Uri(http://www.microsoft.com); 11: Span span new Span(new Run(Span设置字体、颜色等)); 12: span.Foreground new SolidColorBrush(Colors.Green); 13: span.FontSize 18; 14: 15: textBlock.Inlines.InsertBefore(container, content); 16: textBlock.Inlines.InsertBefore(container, new LineBreak()); 17: textBlock.Inlines.InsertBefore(container, bold); 18: textBlock.Inlines.InsertBefore(container, new LineBreak()); 19: textBlock.Inlines.InsertBefore(container, italic); 20: textBlock.Inlines.InsertBefore(container, new LineBreak()); 21: textBlock.Inlines.InsertBefore(container, underline); 22: textBlock.Inlines.InsertBefore(container, new LineBreak()); 23: textBlock.Inlines.InsertBefore(container, hyperlink); 24: textBlock.Inlines.InsertBefore(container, new LineBreak()); 25: textBlock.Inlines.InsertBefore(container, span); 26: textBlock.Inlines.InsertBefore(container, new LineBreak()); 27: 28: // 设置InlineUIContainer的成员 29: panel.Children.Add(new TextBlock(new Run(InlineUIContainer))); 30: Button button new Button(); 31: button.Content Button; 32: button.Width 80; 33: panel.Children.Add(button); 执行结果 四、TextBox模型 System.Windows.Controls.TextBox类实现的是可编辑的文本框文本框的内容由字符串类型的Text属性指定并且整个TextBox的内容使用共同的即TextBox指定的样式。 下载本节的示例代码 本系列博客索引页 转载于:https://www.cnblogs.com/DragonInSea/archive/2009/04/16/1437211.html