我想为Style
定义Template
或GridView
以便轻松设置ItemTemplate类型,而不是每次都将多行代码复制粘贴到<GridView.ItemTemplate><DataTemplate></></>
。< / p>
模板由Grid
和绑定值组成。
下一步将根据某些元素中的更改样式自定义GridView
。
你能给我一些提示吗,因为我有问题。
现在看起来像:
<GridView
x:Name="XSessionsView"
AutomationProperties.AutomationId="ItemsGridView"
AutomationProperties.Name="Items"
TabIndex="1"
Grid.Row="1"
ItemsSource="{Binding Sessions}"
SelectionMode="None"
IsSwipeEnabled="false"
IsItemClickEnabled="True"
ItemContainerStyle="{StaticResource stlol}"
ItemClick="GoToSessionPage_ItemClick">
<GridView.ItemTemplate>
<DataTemplate>
<Grid Width="185" Height="85" x:Name="XProblem"
Margin="10 5 5 10">
<StackPanel Margin="0 5 5 0"
Background="{StaticResource EkSessionBrush}">
<TextBlock Margin="10" FontSize="10">
<Run Text="{Binding StartTimeString}"></Run>
</TextBlock>
<TextBlock Margin="5 10 0 0" FontSize="16"
VerticalAlignment="Bottom">
<Run Text="{Binding Name}"></Run>
</TextBlock>
<TextBlock Margin="5 0 5 5" FontSize="10"
HorizontalAlignment="Right">
<Run Text="{Binding DurationTimeString}"></Run>
</TextBlock>
</StackPanel>
<Rectangle
Width="80" Height="40"
Margin="0 5 5 0"
Fill="Black" Opacity="0.3"
HorizontalAlignment="Right"
VerticalAlignment="Top"/>
<StackPanel Orientation="Horizontal"
Width="80" Height="40"
Margin="0"
Background="{StaticResource EkSessionCorrespondBrush}"
HorizontalAlignment="Right"
VerticalAlignment="Top">
<Viewbox VerticalAlignment="Stretch"
Margin="0"
Height="Auto">
<TextBlock Margin="5">
<Run Text="{Binding SessionAttendance}"/>
<Run Text=" users"
FontSize="10"/>
</TextBlock>
</Viewbox>
</StackPanel>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
我想将XProblem
元素从GridView
中删除。