1

这是我的代码。我已经尝试了几种方法来获取弹出窗口右上角的标签并使其保持在那里,但没有任何效果。谢谢你的帮助!

XAML:

<Window x:Class="ValidationWPF.MainWindow"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                xmlns:local="clr-namespace:ValidationWPF"
                Title="MainWindow" mc:Ignorable="d" 
                xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="259" d:DesignWidth="420" SizeToContent="WidthAndHeight">
    <Grid Height="129" Width="345">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="514*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="0" />
            <RowDefinition Height="251*" />
        </Grid.RowDefinitions>
        <Button Content="Errors" Height="23" HorizontalAlignment="Left" Name="button1" VerticalAlignment="Top" Width="75" Grid.Column="1" Grid.Row="1" Margin="132,12,0,0" MouseEnter="button1_MouseHover">

        </Button>




            <Popup AllowsTransparency="True" PlacementTarget="{Binding ElementName=button1}" StaysOpen="True" AllowDrop="True" Name="PopUp1" PopupAnimation="Scroll">

            <Popup.Child>
          <Border BorderBrush="White" BorderThickness="3, 3, 0, 0">
            <Border BorderBrush="Black" BorderThickness="3, 3, 3, 3">

                <TextBlock Background="Salmon">

                  <Label Background="AliceBlue" Foreground="Black" HorizontalAlignment="Stretch" HorizontalContentAlignment="Right" MouseDown="mouse_DownHandeled" AllowDrop="False" Margin="100,100,0,0">
                    x
                    </Label>

                    <local:ValidationUserControl/>
                </TextBlock>      
            </Border>

        </Border>
         </Popup.Child>
            </Popup>

     </Grid>
</Window>

如您所见,我有一个带有 X 的标签的弹出窗口。标签功能齐全。现在我只需要它看起来像一个正常的弹出窗口,右上角的标签。

4

1 回答 1

0

试试这个:

<TextBlock Background="Salmon" MinWidth="150" MinHeight="150" VerticalAlignment="Top">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="120" />
            <ColumnDefinition Width="30" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="30" />
            <RowDefinition Height="120" />
        </Grid.RowDefinitions>
        <Label Grid.Row="0" Grid.Column="1" Background="AliceBlue" Foreground="Black" VerticalAlignment="Top" AllowDrop="False">
            X
        </Label>
    </Grid>                                
</TextBlock>
于 2012-05-26T11:46:04.787 回答