是否可以将gridview绑定到一个简单的列表? 在数据项模板中,我必须指定属性名称,但在纯字符串列表的情况下,没有任何属性
<DataTemplate x:Key="AppointmentsGroupedItemTemplate"> <StackPanel Width="Auto" Orientation="Horizontal" Height="Auto" Background="Green"> <TextBlock Margin="10,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center" Width="Auto"> <Run Text="{**Binding Name**}" Foreground="Black" FontSize="48"/> </TextBlock> </StackPanel> </DataTemplate>
答案 0 :(得分:0)
如果items source是字符串条目,请使用以下命令:
<DataTemplate x:Key="AppointmentsGroupedItemTemplate">
<StackPanel Width="Auto" Orientation="Horizontal" Height="Auto" Background="Green">
<TextBlock Margin="10,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center" Width="Auto">
<Run Text="{Binding}" Foreground="Black" FontSize="48"/>
</TextBlock>
</StackPanel>
</DataTemplate>