【发布时间】:2015-12-25 21:09:43
【问题描述】:
基本上,我正在尝试在页面顶部创建一个滚动视图,该视图将容纳所有可以水平滚动的日子(如周六周日等)。这是我的MainPage.xaml -
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Get_Weather"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ViewModel="using:Get_Weather.ViewModel"
x:Class="Get_Weather.MainPage"
mc:Ignorable="d">
<Page.DataContext>
<ViewModel:MainViewModel/>
</Page.DataContext>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid>
<ListBox x:Name="listBox" Height="100" Margin="0,0,0,0" Grid.RowSpan="2" VerticalAlignment="Top">
<ListBox.Resources>
<ItemsPanelTemplate x:Key="ItemsPanelTemplate1">
<VirtualizingStackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.Resources>
<ListBox.ItemsPanel>
<StaticResource ResourceKey="ItemsPanelTemplate1"/>
</ListBox.ItemsPanel>
<GridViewItem Content="Saturday"/>
<GridViewItem Content="Sunday"/>
<GridViewItem Content="Monday"/>
<GridViewItem Content="Tuesday"/>
<GridViewItem Content="Wednesday"/>
<GridViewItem Content="Thrusday"/>
<GridViewItem Content="Friday"/>
</ListBox>
</Grid>
</Grid>
</Page>
最初我试图使用DataBindings,就像在这个tutorial 中使用MVVM,但不幸的是它似乎不适用于UWP,因为它在WPF 中,因此当我运行项目时不显示任何东西!所以我决定去老学校硬编码!
对此非常新,因此将不胜感激!
【问题讨论】:
-
尝试设置
<VirtualizingStackPanel Orientation="Horizontal" CanHorizontallyScroll="True"/>,但它给出了错误XBF generation error code 0x09c4和The Property CanHorizontallyScroll was not found in VirtualizingStackPanel