如何在选项卡控件项中拉伸用户控件

时间:2011-02-07 11:00:59

标签: wpf user-controls tabcontrol caliburn.micro stretch

您好我尝试解决拉伸用户控制宽度/高度如何在标签控件中激活到标签控件的宽度/高度。

我使用caliburn micro。

我创建了一些用户控件。这是它:

<UserControl x:Class="Spirit.Views.TabChatView"
             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:Micro="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro" 
             xmlns:Controls="clr-namespace:Spirit.Controls" mc:Ignorable="d" 
             Name="ChatWindow"
             Background="{StaticResource LightGrayBackground}"
             Height="545" Width="680">[...]</UserControl>

此用户控件在shell中处于活动状态,shell声明在此处。

<Window x:Class="Spirit.Views.ChatShellView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro" 
        Title="ChatShellView" Height="300" Width="300">
    <DockPanel>
        <Button x:Name="OpenTab"
                Content="Open Tab" 
                DockPanel.Dock="Top" />
        <TabControl x:Name="Items">
            <TabControl.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding DisplayName}" />
                        <Button Content="X"
                                cal:Message.Attach="CloseItem($dataContext)" />
                    </StackPanel>
                </DataTemplate>
            </TabControl.ItemTemplate>
        </TabControl>
    </DockPanel>
</Window>

如果某个用户控件在此shell中处于活动状态,则可以在此图像上看到:

enter image description here

我想在最大标签控制和/高度上拉伸用户控制。

1 个答案:

答案 0 :(得分:1)

在UserControl定义中删除高度=“545”宽度=“680”

相关问题