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

适合美工的网站网页浏览器电视版

适合美工的网站,网页浏览器电视版,张家口互联网软件园,律所网站建设要求书StackPanel StackPanel 是一种常用的布局控件,可以支持水平或垂直排列,但不会换行。当子元素添加到 StackPanel 中时,它们将按照添加的顺序依次排列。默认情况下,StackPanel 的排列方向是垂直的,即子元素将从上到下依次排列。可以使用 Orientation 属性更改排列方向。可以…

StackPanel

StackPanel 是一种常用的布局控件,可以支持水平或垂直排列,但不会换行。当子元素添加到 StackPanel 中时,它们将按照添加的顺序依次排列。默认情况下,StackPanel 的排列方向是垂直的,即子元素将从上到下依次排列。可以使用 Orientation 属性更改排列方向。可以设置两种排列方式:横排(Horizontal)和竖排(Vertical,默认)。水平排列时,每个元素都与面板一样高;垂直排列时,每个元素都与面板一样宽。

StackPanel 的Orientation属性

1.默认情况下Orientation="Vertical",<StackPanel Orientation="Vertical">与下方加粗字体是同一个效果 

// StackPanel 里添加了4个按钮,默认布局,Orientation 默认垂直排列
<Window x:Class="WpfFirstApp.StackPanelWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfFirstApp"
        mc:Ignorable="d"
        Title="StackPanelWindow" Height="450" Width="800">
    <StackPanel >
        <Button Content="按钮1"></Button>
        <Button Content="按钮2"></Button>
        <Button Content="按钮3"></Button>
        <Button Content="按钮4"></Button>
    </StackPanel>
</Window>

效果图:

也可不在xaml中增加button,改用代码增加;效果是一样的,C#中代码如下:

// 使用C# 代码直接实现
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfFirstApp
{
    /// <summary>
    /// StackPanelWindow.xaml 的交互逻辑
    /// </summary>
    public partial class StackPanelWindow : Window
    {
        public StackPanelWindow()
        {
            InitializeComponent();
            this.Title = "StackPanel面板";
            // StackPanel 默认排列
            StackPanel stackPanel = new StackPanel();
            this.Content = stackPanel;
            stackPanel.Children.Add(new Button(){Content="按钮1"});
            stackPanel.Children.Add(new Button(){Content = "按钮2"});
            stackPanel.Children.Add(new Button(){Content = "按钮3"});
            stackPanel.Children.Add(new Button(){Content = "按钮4"});
        }
    }
}

2.设置StackPanel的Orientation为横向(Horizontal)排列

// 设置 Orientation 属性(Horizontal)
<Window x:Class="WpfFirstApp.StackPanelWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfFirstApp"
        mc:Ignorable="d"
        Title="StackPanelWindow" Height="450" Width="800">
    <StackPanel Orientation="Horizontal">
        <Button Content="按钮1"></Button>
        <Button Content="按钮2"></Button>
        <Button Content="按钮3"></Button>
        <Button Content="按钮4"></Button>
    </StackPanel>
</Window>

效果图:

也可不在xaml中增加button,改用代码增加;效果是一样的,C#中代码如下:

// 使用C# 代码直接实现
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfFirstApp
{
    /// <summary>
    /// StackPanelWindow.xaml 的交互逻辑
    /// </summary>
    public partial class StackPanelWindow : Window
    {
        public StackPanelWindow()
        {
            InitializeComponent();
            this.Title = "StackPanel面板";
            // StackPanel 默认排列
            StackPanel stackPanel = new StackPanel();

            stackPanel.Orientation = Orientation.Horizontal;
            this.Content = stackPanel;
            stackPanel.Children.Add(new Button(){Content="按钮1"});
            stackPanel.Chil

http://www.yayakq.cn/news/606114/

相关文章:

  • 免费查找企业信息的网站深圳市路桥建设集团有限公司招标采购网站
  • 开封市网站建设wordpress土豆
  • 视频网站开发分析成都装修网站制作
  • 安微省住房和城乡建设厅网站张家界有没有做网站的公司
  • wordpress文件锁定了成都黑帽seo
  • html5 微网站布局wordpress免备案cdn
  • 网站登录账号密码保存在哪里江苏建设集团公司官网
  • 聊城手机网站公司做微网站用哪个平台
  • 做自适应网站制作wordpress帖子添加代码
  • 做贸易上什么网站网站建设公司itcask
  • 字体排版网站公众号开发教程视频
  • 怎么给网站添加图标冲压加工瑞安有做网站吗
  • 个人网站首页设计优秀作品网页设计与网站开发试题
  • 泉州企业做网站英大保险公司官网
  • 临沂外贸网站建设北京网站建设哪家好
  • 莲塘网站建设购物网站开店免费
  • 做go kegg的网站做网站前期工作
  • photoshop做网站设计怎样看一个网站的浏览量
  • 免费购物网站系统张家港外贸网站制作
  • 南京企业网站制作哪家好网站百度seo推广怎么做
  • 深圳网站制作公司深圳app开发wordpress链接跳转
  • seo都用在哪些网站用django做的网站
  • 做文献综述的文章用什么网站广西网络网站建设
  • mip网站有什么好处关闭WordPress摘要
  • 百度推广官方网站登录入口哪些网站的登陆界面做的好看
  • 90设计网站最便宜终身搜索引擎营销的特点是
  • 电脑做网站服务器视频教程建设项目验收 网站
  • 网站备案名称中国开头佰维网站建设
  • 软件开发和网站开发难度如何卸载安装wordpress
  • vps搭建网站教程公司网站开发模板