渲染后无法删除网格周围的边框

时间:2018-05-22 05:26:23

标签: wpf xaml

这是我的XAML,我看到网格周围的边框,我不知道如何删除它。

 <Border
        BorderBrush="#971c1c"
        BorderThickness="5"
        CornerRadius="5">
        <Grid Background="#971c1c">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Image
                Width="20"
                Height="20"
                Margin="3"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Source="/DataSuite.Administration.Console.WinClient;component/Resources/Integration_Error.png" />
            <ItemsControl
                Grid.Column="1"
                Margin="0,5"
                BorderThickness="0"
                FontSize="14"
                Foreground="White">
                <ListBoxItem>
                    <TextBlock Text="This is sample text for the error. Width will be set as per the value of message" />
                </ListBoxItem>
                <ListBoxItem>
                    <TextBlock Text="This is sample text for the error." />
                </ListBoxItem>
                <ListBoxItem>
                    <TextBlock Text="This is sample text for the error." />
                </ListBoxItem>
            </ItemsControl>
            <Button
                Grid.Column="2"
                VerticalAlignment="Center"
                Background="Transparent"
                BorderThickness="0"
                Foreground="White">
                Dissmiss
                <Button.Style>
                    <Style>
                        <Style.Triggers>
                            <Trigger Property="Control.IsMouseOver" Value="True">
                                <Setter Property="Control.Cursor" Value="Hand" />
                                <Setter Property="Control.Background" Value="Transparent" />
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </Button.Style>
            </Button>
        </Grid>
    </Border>

我已经从Itemscontrol中删除了边框,而且这个xaml也是usercontrol的一部分,我也将usercontrol的Borderthickness设置为0

这是我看到的输出。

Rendered Image

2 个答案:

答案 0 :(得分:0)

最简单的方法是将网格上的边距设置为-1。

 <Grid Background="#971c1c" Margin="-1">

答案 1 :(得分:0)

尝试设置边框的背景而不是网格。

<Border
    Background="#971c1c"
    BorderThickness="0"
    CornerRadius="5">
    <Grid>

    </Grid>
</Border>