WPF - 奇怪的对齐行为

时间:2012-07-19 16:55:06

标签: wpf layout user-controls

我有以下代码:

<UserControl x:Class="BluetoothAdvertisingSoftwareWPF.DeviceControl"
         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" 
         mc:Ignorable="d" 
         d:DesignHeight="72" d:DesignWidth="72">
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="4*"></RowDefinition>
        <RowDefinition Height="*"></RowDefinition>
    </Grid.RowDefinitions>
    <Rectangle Grid.Row="0" Width="50" Height="50" Name="DeviceRectangle">
        <Rectangle.Fill>
            <ImageBrush ImageSource="ImagesDevices/MobilePhone.jpg"></ImageBrush>
        </Rectangle.Fill>
    </Rectangle>
    <Label Name="lblDeviceName" Grid.Row="1"></Label>
</Grid>

但是矩形对齐到父控件的中心,而不是我的UserControl

为什么?

0 个答案:

没有答案
相关问题