列表框 Windows 10 通用 Header
ListBox Windows 10 Universal Header
我在 xaml:
中成功添加了一个带有数据绑定的列表框
但是我忘记了要为项目使用哪个属性 header。我的项目包含文本框 "name"、"money earned",如果我添加项目,我的项目会说例如 "Mustermann"、“300”,但我需要在项目上方显示一个 header 模板,上面写着"name" 和 "money earned" 如何为项目添加这样的 header?
我已经写的 xaml 与这个问题无关,但如果您有兴趣:
<ListBox x:Name="WorkersList" ItemsSource="{Binding}" MaxWidth="480" MaxHeight="400" VerticalAlignment="Top" HorizontalAlignment="Left">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding name}" HorizontalAlignment="Center" Width="100"></TextBlock>
<TextBlock Text="{Binding gehalt}" HorizontalAlignment="Center" Width="100"></TextBlock>
<ToggleSwitch></ToggleSwitch>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
您可以将 ListView 与 GridView 一起使用。在每个GridViewColumn
中,有一个属性叫做Header
。
编辑:
您可以使用 ListView
. Apparently there is a ListView.Header
property in W10 apps. Have a look at this。像下面这样的东西可以工作:
<ListView>
<ListView.Header>
<StackPanel>
<TextBlock Text="Name"/>
<TextBlock Text="Money earned"/>
</StackPanel>
</ListView.Header>
</ListView>
首先,ListBox不支持Header
我不确定我是否正确理解你的问题,但如果你的意思是你想要 Table 之类的东西(里面有 header 和数据)我建议你使用一些有用 类 喜欢 MyToolkit (DataGrid)
我在 xaml:
中成功添加了一个带有数据绑定的列表框但是我忘记了要为项目使用哪个属性 header。我的项目包含文本框 "name"、"money earned",如果我添加项目,我的项目会说例如 "Mustermann"、“300”,但我需要在项目上方显示一个 header 模板,上面写着"name" 和 "money earned" 如何为项目添加这样的 header?
我已经写的 xaml 与这个问题无关,但如果您有兴趣:
<ListBox x:Name="WorkersList" ItemsSource="{Binding}" MaxWidth="480" MaxHeight="400" VerticalAlignment="Top" HorizontalAlignment="Left">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding name}" HorizontalAlignment="Center" Width="100"></TextBlock>
<TextBlock Text="{Binding gehalt}" HorizontalAlignment="Center" Width="100"></TextBlock>
<ToggleSwitch></ToggleSwitch>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
您可以将 ListView 与 GridView 一起使用。在每个GridViewColumn
中,有一个属性叫做Header
。
编辑:
您可以使用 ListView
. Apparently there is a ListView.Header
property in W10 apps. Have a look at this。像下面这样的东西可以工作:
<ListView>
<ListView.Header>
<StackPanel>
<TextBlock Text="Name"/>
<TextBlock Text="Money earned"/>
</StackPanel>
</ListView.Header>
</ListView>
首先,ListBox不支持Header
我不确定我是否正确理解你的问题,但如果你的意思是你想要 Table 之类的东西(里面有 header 和数据)我建议你使用一些有用 类 喜欢 MyToolkit (DataGrid)