【发布时间】:2015-03-31 04:00:46
【问题描述】:
我正在尝试遵循这个 SO answer,但是我是 Visual Studio 正在抱怨 Windows 应用程序项目中不支持 Datagrid?我可以使用 Datagrid 的替代品吗?
最终我想创建一个按钮网格,对应于 List menuLists 中的 MenuItem。
我是数据绑定的新手,所以如果有人有更好的东西我应该看看,请告诉我。
<Page
x:Class="App1.Pages.MenuItemsPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1.Pages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<CollectionViewSource x:Key="MenuItemsCollectionViewSource" Source="{Binding MenuItems}"/>
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<DataGrid Grid.Row ="0" ItemsSource ="{Binding Source = {StaticResource MenuItemsCollectionViewSource}}" />
</Grid>
</Page>
【问题讨论】: