0

我有一个 TabControl,它有四个标签。它的xml是:

![enter image description here][1]<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
<Grid>
    <TabControl Height="282" HorizontalAlignment="Left" Name="tabControl1"      
     VerticalAlignment="Top" Width="503">
        <TabItem Header="tabItem1" Name="tabItem1">
            <Grid >
                <Grid.RowDefinitions>
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="101*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="367"/>
                    <ColumnDefinition Width="125*" />
                </Grid.ColumnDefinitions>
                <Label Content="Library:" Height="28" HorizontalAlignment="Left" Margin="309,15,0,0" Name="label1" VerticalAlignment="Top" Width="49" />
                <Label  Content="Museum:" Height="28" HorizontalAlignment="Left" Margin="303,13,0,0" Name="label2" VerticalAlignment="Top" Width="58" Grid.Row="1" />
                <Label Content="Cinema:" Height="28" HorizontalAlignment="Left" Margin="309,11,0,0" Name="label3" VerticalAlignment="Top" Width="50" Grid.Row="2" />
                <Label Content="Embankment:" Height="28" HorizontalAlignment="Left" Margin="281,30,0,0" Name="label4" VerticalAlignment="Top" Width="81" Grid.Row="3" />
            </Grid>
        </TabItem>
    </TabControl>
</Grid>

当程序运行时,一些字母、标志消失了,我不明白为什么。例如,在此屏幕截图中,可以看到单词“Cinema”的冒号未绘制。我做了一个网格,但是,它没有帮助。我应该怎么做才能使我的程序正常工作?它经常发生。我希望我的所有标签都能正确显示。

可以看出没有画出“Cinema”这个词的冒号

两个木偶

4

1 回答 1

1

尝试删除标签的“宽度”并允许内容调整控件的大小

<Grid>
        <TabControl Height="282" HorizontalAlignment="Left" Name="tabControl1"      
     VerticalAlignment="Top" Width="503">
            <TabItem Header="tabItem1" Name="tabItem1">
                <Grid >
                    <Grid.RowDefinitions>
                        <RowDefinition Height="50"/>
                        <RowDefinition Height="50"/>
                        <RowDefinition Height="50"/>
                        <RowDefinition Height="101*" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="367"/>
                        <ColumnDefinition Width="125*" />
                    </Grid.ColumnDefinitions>
                    <Label Content="Library:" Height="28" HorizontalAlignment="Left" Margin="309,15,0,0" Name="label1" VerticalAlignment="Top"  />
                    <Label  Content="Museum:" Height="28" HorizontalAlignment="Left" Margin="303,13,0,0" Name="label2" VerticalAlignment="Top"  Grid.Row="1" />
                    <Label Content="Cinema:" Height="28" HorizontalAlignment="Left" Margin="309,11,0,0" Name="label3" VerticalAlignment="Top"  Grid.Row="2" />
                    <Label Content="Embankment:" Height="28" HorizontalAlignment="Left" Margin="281,30,0,0" Name="label4" VerticalAlignment="Top"  Grid.Row="3" />
                </Grid>
            </TabItem>
        </TabControl>
    </Grid>
于 2012-11-27T23:13:33.520 回答