Ella486900 2021-09-10 09:21 采纳率: 0%
浏览 21

(WPF初学者)Button和Gird相互覆盖怎么解决

我在Grid下设置了一个渐变的Grid.Background和一个普通的Button按钮,但是,加了按钮之后背景就没有了,这时怎么回事?

<Window x:Class="Buttin._1.MainWindow"
        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:Buttin._1"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <Grid.Background>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="Red" Offset="0"/>
                <GradientStop Color="Yellow" Offset="0.6"/>
                <GradientStop Color="AliceBlue" Offset="1"/>
            </LinearGradientBrush>

        </Grid.Background>
        <Button>
            <Button.Content >
                <StackPanel Orientation="Vertical" Height="240">
                    <Image Source="a.jpg" Width="150" Height="200"/>
                    <TextBox Text="Smile" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="30"/>
                </StackPanel>
            </Button.Content>
        </Button>
    </Grid>
</Window>

img

img

  • 写回答

2条回答 默认 最新

  • hxycsdn9159 2021-09-10 09:53
    关注

    按钮太大了,设置一下按钮的width和height

    评论

报告相同问题?

问题事件

  • 创建了问题 9月10日

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog