Home > Net >  WPF ListBox using DataTemplate data binding, show only a line, line does not show much
WPF ListBox using DataTemplate data binding, show only a line, line does not show much

Time:11-11

XAML code:
XMLNS="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
XMLNS: x="http://schemas.microsoft.com/winfx/2006/xaml"
XMLNS: d="http://schemas.microsoft.com/expression/blend/2008"
XMLNS: MC="http://schemas.openxmlformats.org/markup-compatibility/2006"
XMLNS: local="CLR namespace: WPF_125P"
MC: Ignorable="d"
Title="Date Converter" Height="266" Width="300" & gt;






Source="{Binding Path=the category, the Converter={StaticResource CTS}}"/& gt; -->
IsChecked="{Binding Path=the state that the Converter={StaticResource STNB}}"/& gt; -->




Click="buttonSave_Click"/& gt;





C # key code:
Private void buttonLoad_Click (object sender, RoutedEventArgs e)
{

List Planes=new List ()
{
New Plane () {category=category. Fighter, Name="b-1", state=state. The Unknown},
New Plane () {category=category. 'bomber, Name="B - 2", the state=state. The Unknown},
New Plane () {category=category. Fighter, Name="F - 22", state=state. The Unknown},
New Plane () {category=category. Fighter, Name="Su - 47," state=state. The Unknown},
New Plane () {category=category. 'bomber, Name="B - 52", the state=state. The Unknown},
New Plane () {category=category. Fighter, Name="J - 10", the state=state. The Unknown},
};
Enclosing listBoxPlane. ItemsSource=planes;
}

CodePudding user response:

Shows the line didn't show much are you sure you don't consider your UI problem? You this listbox the height of the height of an item is 160, 160 (80 + 80) two textblock

CodePudding user response:

To this:

CodePudding user response:

 




  •  Tags:  
  • C#
  • Related