Usercontrol background color not changes even afte

2019-09-09 21:00发布

Hi i have designed a usercontrol for using as an pop up and i have set the usercontrol background property as transperent but the background is not getting transperent enter image description here

I need that light orange to be transparent

and here is my xaml code of user control

<UserControl
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Class="WPFTest.UCToolTip" 
         mc:Ignorable="d" Height="231.493" Width="362.075"
         Background="Transparent"  >
<UserControl.Resources>
    <Style TargetType="{x:Type Hyperlink}">
                 <Setter Property="TextBlock.TextDecorations" Value="{x:Null}" />
    </Style>
</UserControl.Resources>
<Grid Margin="10,0,0,0">
    <Grid.RowDefinitions>
        <RowDefinition/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <Grid Background="Orange" Margin="0,0,0,33">
        <!--Your content here-->
    </Grid>
    <Polygon
    Points="0,0 15,0, 0,30" Stroke="Orange" Fill="Orange" Margin="0,198,0,1" />
</Grid>

1条回答
欢心
2楼-- · 2019-09-09 21:43

The problem seems to be that you're using the Grid incorrectly. You need to specify which row the items are in, and once you do that, you don't need all those margins. And your first row needs to have Height="Auto" so it expands to fit the content within it.

<Grid>
    <Grid Margin="10,0,0,0">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0"  Background="Orange" Margin="0,0,0,0" >
            <Label>My Content</Label>
        </Grid>
        <Polygon 
            Grid.Row="1" 
            Points="0,0 15,0, 0,30" 
            Stroke="Orange" 
            Fill="Orange" 
            Margin="0,0,0,1" />
    </Grid>
</Grid>
查看更多
登录 后发表回答