我想将包含第5个对象属性中的enum(website?[])数组的对象列表绑定到数据网格中
这是我的xaml代码:
<DataGrid x:Name="dataGrid" AutoGenerateColumns="False" IsReadOnly="True" FontFamily="Lucida Bright" FontSize="30" LoadingRow="dataGrid_LoadingRow" >
<DataGrid.Columns>
<DataGridTextColumn Header="Apartment id" Binding="{Binding appartId}" FontFamily="Corbel" FontSize="23" Width="auto"/>
<DataGridTextColumn Header="City" Binding="{Binding place}" FontFamily="Corbel" FontSize="23" Width="auto"/>
<DataGridTextColumn Header="Address" Binding="{Binding roomNb}" FontFamily="Corbel" FontSize="23" Width="*"/>
<DataGridTextColumn Header="Rooms" Binding="{Binding city}" FontFamily="Corbel" FontSize="23" Width="auto"/>
<DataGridTemplateColumn Header="Registered on">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
我尝试使用datatemplatecolumn
,但是我没有成功绑定第5个元素,该元素是可为空的枚举数组
我想在第五列中仅显示!= null的元素
例如:
appartment id | city | adress | rooms | websiteList
465 paris yello st. 4 airbnb
rental
holidaysletting
47 tokyo ki st. 8 rental
这是我的代码
IEnumerable<BE.appartCl> ll;
BL.Interface2 bl = BL.factoryBL.GetBL();
public databaseP()
{
ll = bl.GetListApp();
InitializeComponent();
dataGrid.ItemsSource = ll;
}
这是我的课程
public enum site { Airbnb, Holidaylettings, Booking, Homelidays, Homeaway,
Sublet }
public class appartCl
{
[XmlElement("appartId")]
public int appartId { get; set; }
[XmlElement("place")]
public string place { get; set; }
[XmlElement("roomNb")]
public int roomNb { get; set; }
[XmlElement("city")]
public string city { get; set; }
[XmlArray("siteSt")]
public site?[] siteSt = new site?[10];
[XmlArray("recSt")]
public string[] recSt = new string[10];
[XmlArray("dateIn")]
public List<string> dateIn { get; set; }
[XmlArray("dateOut")]
public List<string> dateOut { get; set; }
}