更改用户控件的大小

时间:2017-03-11 07:53:19

标签: c# wpf visual-studio user-controls office-addins

我在确定哪个元素导致尺寸错位时遇到问题。这是一张图片来说明它:click here to see it

浅灰色区域是我想要改变的元素大小,但不能。整个区域是用户控件,Tab内的区域是WPF(作为元素主机)。我尝试过更改两者,但对灰色区域没有影响(其他标签也受此影响)。 以下是托管元素(WPF)的代码

<UserControl x:Class="SlideAnalyzer.DisplayAnalysis"
         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:local="clr-namespace:SlideAnalyzer"
         mc:Ignorable="d" 
         d:DesignHeight="150.8" d:DesignWidth="201.2">


<Grid Name="displayGrid" Height="64" VerticalAlignment="Bottom" HorizontalAlignment="Center" Width="160" Margin="10,0,31.6,9.4" RenderTransformOrigin="0.496,0.94">

    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <Expander x:Name="expander" Grid.Row="0"  Header="Titel zu lang" HorizontalAlignment="Left" VerticalAlignment="Top" Width="180" Background="Red" Margin="-10,-56,0,0">

        <Grid Background="AliceBlue">
            <TextBlock TextWrapping="Wrap"
                   Margin="5"><Run Text="This is some text content."/></TextBlock>

        </Grid>

    </Expander>
</Grid>

主机本身是普通的用户控件。我似乎无法获得正确的托管元素大小,以便预览真正反映现实(因为当我运行加载项时,WPF的大小不同)

我尝试更改UserControl的属性,发现 AutoSize 在True时有很大影响(默认为False)  谢谢!

0 个答案:

没有答案
相关问题