Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xaml 垂直输入ListBoxItem_Xaml_Listbox_Windows Phone 8.1 - Fatal编程技术网

Xaml 垂直输入ListBoxItem

Xaml 垂直输入ListBoxItem,xaml,listbox,windows-phone-8.1,Xaml,Listbox,Windows Phone 8.1,下面是我的XAML代码,用于设计带有选择突出显示的水平菜单。我实现了突出显示所选项目的功能,但每个项目显示的项目都采用了完整的设计 <ListBox x:Name="ListboxTest" ItemsSource="{Binding ScheduleScreenItems}" Background="Gray" ScrollViewer.HorizontalScrollBarVisibility="Hidden" SelectionChanged="ListboxTest_Selec

下面是我的XAML代码,用于设计带有选择突出显示的水平菜单。我实现了突出显示所选项目的功能,但每个项目显示的项目都采用了完整的设计

 <ListBox x:Name="ListboxTest" ItemsSource="{Binding ScheduleScreenItems}"  Background="Gray" ScrollViewer.HorizontalScrollBarVisibility="Hidden" SelectionChanged="ListboxTest_SelectionChanged" ScrollViewer.VerticalScrollBarVisibility="Disabled"  SelectionMode="Single">
                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="ListBoxItem">
                                    <Grid>
                                        <VisualStateManager.VisualStateGroups>
                                            <VisualStateGroup x:Name="CommonStates">
                                                <VisualState x:Name="Normal"/>
                                            </VisualStateGroup>
                                            <VisualStateGroup x:Name="SelectionStates">
                                                <VisualState x:Name="Unselected">
                                                    <Storyboard>
                                                        <ColorAnimation Duration="0" Storyboard.TargetName="myback" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" To="Transparent"/>
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="SelectedUnfocused">
                                                    <Storyboard>
                                                        <ColorAnimation Duration="0" Storyboard.TargetName="myback" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" To="Red"/>
                                                    </Storyboard>
                                                </VisualState>
                                            </VisualStateGroup>
                                        </VisualStateManager.VisualStateGroups>
                                        <Border x:Name="myback" Background="Transparent">
                                            <ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
                                        </Border>
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListBox.ItemContainerStyle>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel  >
                            <TextBlock Text="{Binding DayName}" FontFamily="Times New Roman" FontWeight="SemiBold" Height="25" TextAlignment="Center"    Padding="0 0 0 0" Margin="0 0 0 0" Width="100" FontSize="18" Foreground="White"  HorizontalAlignment="Center"/>
                            <TextBlock Text="{Binding Date}"   FontWeight="SemiBold"  FontSize="18" Margin="0 10 0 0" Foreground="White" HorizontalAlignment="Center"  />
                            <Line   X1="0" Y1="-70"  X2="0" Y2="50"
                                        Stroke="White"
                                  StrokeThickness="2" />
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

预期菜单设计为

但我会把每一部分一个接一个地垂直排列


请指导我解决这个问题。

您应该将
项spanelTemplate的
方向更改为
水平方向

<ListBox  ItemsSource="{Binding ListTest}"  ScrollViewer.HorizontalScrollMode="Enabled" ScrollViewer.HorizontalScrollBarVisibility="Visible"
                      ScrollViewer.VerticalScrollMode="Disabled"
                     x:Name="MyListView">
        <ListBox.ItemContainerStyle>
            <Style TargetType="ListBoxItem">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ListBoxItem">
                            <Grid>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="CommonStates">
                                        <VisualState x:Name="Normal"/>
                                    </VisualStateGroup>
                                    <VisualStateGroup x:Name="SelectionStates">
                                        <VisualState x:Name="Unselected">
                                            <Storyboard>
                                                <ColorAnimation Duration="0" Storyboard.TargetName="myback" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" To="Transparent"/>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="SelectedUnfocused">
                                            <Storyboard>
                                                <ColorAnimation Duration="0" Storyboard.TargetName="myback" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" To="Red"/>
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                                <Border x:Name="myback" Background="Transparent">
                                    <ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
                                </Border>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ListBox.ItemContainerStyle>
        <ListBox.ItemTemplate>

            <DataTemplate >
                <StackPanel Orientation="Vertical"    >
                    <TextBlock Text="{Binding Name}"/>
                    <Line   X1="0" Y1="-70"  X2="0" Y2="50"
                                    Stroke="White"
                              StrokeThickness="2" />
                </StackPanel>

            </DataTemplate>
        </ListBox.ItemTemplate>
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Horizontal" />
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
    </ListBox>


将这个
ScrollViewer.HorizontalScrollMode=“Enabled”
添加到
ListView
中,谢谢@LovetoCode的回复。我包括但不起作用。很抱歉你也应该添加这些。你能具体指导我在哪里更新代码添加的答案吗。请参考这篇文章,你能推荐一些其他可行的选择吗。我只是测试一下。它起作用了。我将添加整个代码。只要检查一下谢谢@LovetoCode。它起作用了。但这份名单还没有全部公布。菜单上有周四、周五、周六、周日、周一、周二和周三。在菜单设计中,我可以使用scrollgive
ScrollViewer.HorizontalScrollBarVisibility=“Hidden”
或visible
ScrollViewer.HorizontalScrollBarVisibility=“visible”
感谢@LovetoCode获得完整的列表。它的工作和预期的一样完美