ScrollViewer的ScrollBar在Windows Phone 7中不可见 [英] ScrollBar of the ScrollViewer is not Visible in Windows Phone 7
问题描述
我正在使用 Microsoft Windows Phone开发人员工具Beta -ENU。 (今天刚下载)
I'm working with Microsoft Windows Phone Developer Tools Beta -ENU. (Just downloaded it today)
ScrollViewer的ScrollBar在以下示例中不可见。任何想法?
ScrollBar of the ScrollViewer is not Visible in the following example. Any Idea?
MainPage.xaml
< phone:PhoneApplicationPage
x:Class =" WindowsPhoneApplication1.MainPage"
xmlns =" http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x =" http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone =" clr-namespace:Microsoft.Phone.Controls; assembly = Microsoft.Phone"
xmlns:shell =" clr-namespace:Microsoft.Phone.Shell; assembly = Microsoft.Phone"
xmlns:d =" http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc =" http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily =" {StaticResource PhoneFontFamilyNormal}"
FontSize =" {StaticResource PhoneFontSizeNormal}"
Foreground =" {StaticResource PhoneForegroundBrush}"
SupportedOrientations = QUOT;肖像" Orientation =" Portrait"
MC:可忽略= QUOT; d" d:DesignWidth = QUOT; 480" d:DesignHeight =" 768"
shell:SystemTray.IsVisible =" True">
<! - LayoutRoot包含放置所有其他页面内容的根网格 - >
< Grid x:Name =" LayoutRoot"背景="透明">
< Grid.RowDefinitions>
< RowDefinition Height =" Auto" />
< RowDefinition Height =" *" />
< /Grid.RowDefinitions>
<! - TitlePanel包含应用程序的名称和页面标题 - >
< StackPanel x:Name =" TitlePanel" Grid.Row = QUOT; 0"保证金=" 24,24,0,12">
< TextBlock x:Name =" ApplicationTitle"文字="我的申请" Style =" {StaticResource PhoneTextNormalStyle}" />
< TextBlock x:Name =" PageTitle" Text =" page name"余量= QUOT; -3,-8,0,0" Style =" {StaticResource PhoneTextTitle1Style}" />
< / StackPanel>
<! - ContentPanel - 在此处添加其他内容 - >
< Grid x:Name =" ContentGrid" Grid.Row = QUOT 1 QUOT;>结果,
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; <的ScrollViewer背景= QUOT;黄色" ; VerticalScrollBarVisibility = QUOT;可见" HorizontalScrollBarVisibility = QUOT;可见"余量= QUOT; 40,58,39,86">结果,
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ; < ScrollViewer.Content>结果,
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ; < Canvas Height =" 347"背景= QUOT;红色"宽度= QUOT; 15000">< /画布>结果,
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < /ScrollViewer.Content>
< / ScrollViewer>
< / Grid>
< / Grid>
<! - 显示ApplicationBar用法的示例代码
< phone:PhoneApplicationPage.ApplicationBar>
< shell:ApplicationBar IsVisible =" True" IsMenuEnabled =" True">
< shell:ApplicationBarIconButton x:Name =" appbar_button1" IconUri = QUOT; /Images/appbar_button1.png" Text =" Button 1"< / shell:ApplicationBarIconButton>
< shell:ApplicationBarIconButton x:Name =" appbar_button2" IconUri = QUOT; /Images/appbar_button2.png"文本= QUOT;按钮2英寸;>< /壳:ApplicationBarIconButton>结果,
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < shell:ApplicationBar.MenuItems>
< shell:ApplicationBarMenuItem x:Name =" menuItem1"文本= QUOT;菜单项1">< /壳:ApplicationBarMenuItem>结果,
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP; < shell:ApplicationBarMenuItem x:Name =" menuItem2" Text =" MenuItem 2"< / shell:ApplicationBarMenuItem>
< / shell:ApplicationBar.MenuItems>
< / shell:ApplicationBar>
< / phone:PhoneApplicationPage.ApplicationBar>
- >
< / phone:PhoneApplicationPage>
<phone:PhoneApplicationPage
x:Class="WindowsPhoneApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot contains the root grid where all other page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="24,24,0,12">
<TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="page name" Margin="-3,-8,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentGrid" Grid.Row="1">
<ScrollViewer Background="Yellow" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible" Margin="40,58,39,86">
<ScrollViewer.Content>
<Canvas Height="347" Background="red" Width="15000"></Canvas>
</ScrollViewer.Content>
</ScrollViewer>
</Grid>
</Grid>
<!-- Sample code showing usage of ApplicationBar
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton x:Name="appbar_button1" IconUri="/Images/appbar_button1.png" Text="Button 1"></shell:ApplicationBarIconButton>
<shell:ApplicationBarIconButton x:Name="appbar_button2" IconUri="/Images/appbar_button2.png" Text="Button 2"></shell:ApplicationBarIconButton>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem x:Name="menuItem1" Text="MenuItem 1"></shell:ApplicationBarMenuItem>
<shell:ApplicationBarMenuItem x:Name="menuItem2" Text="MenuItem 2"></shell:ApplicationBarMenuItem>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
-->
</phone:PhoneApplicationPage>
MainPage.xaml.cs
使用System;
使用System.Collections.Generic;
使用System.Linq;
使用System.Net;
使用System.Windows;
使用System.Windows.Controls;
使用System.Windows.Documents;
使用System.Windows.Input;
使用System.Windows.Media;
使用System.Windows.Media.Animation;
使用System.Windows.Shapes;
使用Microsoft.Phone.Controls;
命名空间WindowsPhoneApplication1
{
public partial class MainPage:PhoneApplicationPage
{
//构造函数
public MainPage()
{
InitializeComponent();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
namespace WindowsPhoneApplication1
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}
}
}
推荐答案
您没有任何限制网格大小的内容,因此它的子项只会在需要时变大。
You don't have anything limiting the size of your grid so it's children just grow larger as and when needed.
而不是使用自动尝试固定高度开始。
Instead of using Auto try a fixed height to begin with.
这篇关于ScrollViewer的ScrollBar在Windows Phone 7中不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!