加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – WPF新手,如何在表单中创建这些彩色条?

发布时间:2020-12-15 06:32:34 所属栏目:百科 来源:网络整理
导读:我试图抛弃 Windows窗体,并从现在开始学习如何专业地使用WPF.上图是在Windows窗体中完成的一个表单,我想在WPF中重新创建. 这是我到目前为止的XAML: Window x:Class="PizzaSoftware.UI.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/pre
我试图抛弃 Windows窗体,并从现在开始学习如何专业地使用WPF.上图是在Windows窗体中完成的一个表单,我想在WPF中重新创建.

这是我到目前为止的XAML:

<Window x:Class="PizzaSoftware.UI.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="297" Width="466" >
    <Grid ShowGridLines="True">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width=".20*"/>
            <ColumnDefinition />
            <ColumnDefinition Width=".20*"/>    
        </Grid.ColumnDefinitions>     
        <Rectangle Grid.Column="0">
            <Backcolor?
        </Rectangle>
    </Grid>
</Window>

这是否是正确的方法,我的意思是使用矩形.在我的Windows窗体示例中,我使用了Panel并为其提供了.BackColor属性.

什么是WPF实现这一目标的方式?

谢谢.

解决方法

是的,你的方法很好.使用Fill属性设置背景颜色:
<Rectangle Grid.Column="0" Fill="Orange" />
            <Rectangle Grid.Column="2" Fill="Orange" />

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读