【发布时间】:2016-02-08 00:30:46
【问题描述】:
我在创建 xaml 控件时遇到问题。我正在通用应用程序中的 VS 2015 中编写新项目。我想创建网格。在这个网格中,我想要一个按钮。在模型中,我指定列(级别)和行。 这是我的代码:
<ItemsControl Grid.Row="1" ItemsSource="{Binding Path=TechnologyList}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="10*"/>
<RowDefinition Height="10*"/>
<RowDefinition Height="10*"/>
<RowDefinition Height="10*"/>
<RowDefinition Height="10*"/>
<RowDefinition Height="10*"/>
<RowDefinition Height="10*"/>
<RowDefinition Height="10*"/>
<RowDefinition Height="10*"/>
<RowDefinition Height="10*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="14*"/>
<ColumnDefinition Width="14*"/>
<ColumnDefinition Width="14*"/>
<ColumnDefinition Width="14*"/>
<ColumnDefinition Width="14*"/>
<ColumnDefinition Width="14*"/>
<ColumnDefinition Width="14*"/>
</Grid.ColumnDefinitions>
</Grid>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="Control">
<Setter Property="Grid.Column" Value="{Binding Level}" />
<Setter Property="Grid.Row" Value="{Binding Row}" />
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Content="{Binding Name}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Setter Property="Grid.Column" Value="{Binding Level}" /> 行出现错误
错误:来自 HRESULT 的异常:0x8000FFFF (E_UNEXPECTED) 在 edytor 中而不是在运行代码中。
怎么了?在“旧”WPF 中一切正常,但在适用于 Windows 10 的通用应用程序中出现错误。
谁能帮我 ?
【问题讨论】:
-
如何在 UWP 中做这样的事情?
标签: c# xaml win-universal-app setter itemcontainerstyle