通用Windows应用程序的水平StackPanel滚动视图

时间:2015-09-28 15:02:08

标签: c# wpf xaml mvvm uwp

基本上我试图在页面顶部创建一个滚动视图,它将保存所有日子(如星期六星期日等),可以水平滚动。这是我的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 MVVM使用UWP,但不幸的是,它似乎不适用于WPF,因为它在{ {1}}因此,当我运行项目时,它不会显示任何内容!所以我决定去老学校并硬编码! 非常新的,所以帮助将不胜感激!

1 个答案:

答案 0 :(得分:0)

需要将ScrollViewer.Horizo​​ntalScrollMode设置为Auto。

$rootScope
相关问题