簡體   English   中英

Universal Windows App的水平StackPanel滾動視圖

[英]Horizontal StackPanel Scroll view for Universal Windows App

基本上,我試圖在頁面頂部創建一個滾動視圖,該視圖將保持所有天數(例如周六周日等),並且可以水平滾動。 這是我的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>

最初,我試圖在本教程中使用MVVM來使用DataBindings ,但不幸的是,它似乎不適用於UWP就像在WPF ,因此,當我運行項目時,它不顯示任何內容! 因此,我決定去舊學校並對其進行硬編碼! 這是新手,所以將不勝感激!

ScrollViewer.Horizo​​ntalScrollMode需要設置為“自動”。

<ListBox x:Name="listBox" Height="100" Margin="0,0,0,0" Grid.RowSpan="2" VerticalAlignment="Top" ScrollViewer.HorizontalScrollMode="Auto">
    <ListBox.Resources>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM