如何利用ListBoxItem WPF中的空间
我的数据模板中有两个标签,我希望看到标签中的所有文本,但文本被剪掉了。我想看到所有的文字,文字应该居中。我增加了标签的高度,但文本没有居中。当我将“包裹面板最大高度”(wrap panel max height)设置为20时出现此问题,我需要将其设置为20。我想以相同的字体大小垂直居中文本。我已将标签的最小高度设置为30,但文本没有垂直居中 在列表框中剪切标签 将标签元素的Padding属性设置为0或使用TextBlocks:如何利用ListBoxItem WPF中的空间,wpf,listbox,datatemplate,Wpf,Listbox,Datatemplate,我的数据模板中有两个标签,我希望看到标签中的所有文本,但文本被剪掉了。我想看到所有的文字,文字应该居中。我增加了标签的高度,但文本没有居中。当我将“包裹面板最大高度”(wrap panel max height)设置为20时出现此问题,我需要将其设置为20。我想以相同的字体大小垂直居中文本。我已将标签的最小高度设置为30,但文本没有垂直居中 在列表框中剪切标签 将标签元素的Padding属性设置为0或使用TextBlocks: <DataTemplate x:Key="dtTeamInGa
<DataTemplate x:Key="dtTeamInGame">
<WrapPanel MaxHeight="20" >
<Label x:Name="txtPath" Content="{Binding Path = FirstName, Mode=TwoWay}" MinWidth="35" FontStretch="Expanded" ></Label>
<Label x:Name="txtPath2" Content="{Binding Path = SurName, Mode=TwoWay}" MinWidth="125" ></Label>
</WrapPanel>
</DataTemplate>
<ListBox x:Name="listBox" ItemTemplate="{DynamicResource dtTeamInGame}" HorizontalAlignment="Left" Height="100" Margin="97,206,0,0" VerticalAlignment="Top" Width="381">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<EventSetter Event="PreviewMouseLeftButtonDown" Handler="ListViewItem_PreviewMouseLeftButtonDownHome" />
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
<DataTemplate x:Key="dtTeamInGame">
<WrapPanel MaxHeight="20">
<Label x:Name="txtPath" Content="FirstName" MinWidth="35" FontStretch="Expanded" Padding="0"></Label>
<Label x:Name="txtPath2" Content="Surname" MinWidth="125" Padding="0"></Label>
</WrapPanel>
</DataTemplate>