我有一个TabControl,它有四个标签。它的xaml是:
![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”这个词的冒号。
答案 0 :(得分: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>