我的Windows Phone頁面上有一個ScrollViewer。 我想顯示有一個滾動的可能性expllicitly。默認情況下,控件本身不顯示任何可以向用戶提示該空間是可滾動的提示。 例如,是否有可能總是在右側顯示滾動條?同樣,默認情況下,僅當用戶想要並嘗試滾動時才顯示它。ScrollViewer邊框(Windows Phone 7)
0
A
回答
1
<ScrollViewer VerticalScrollBarVisibility="Visible">
不能在windows phone中工作。我認爲你可以更改ScrollViewer的ControTemplate並使滾動條可見。
編輯:
是您如何更改ScrolViewer控制模板的示例。我是從MSDN
<Style x:Key="LeftScrollViewer" TargetType="ScrollViewer">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ScrollViewer">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ScrollContentPresenter Grid.Column="1"/>
<ScrollBar Name="PART_VerticalScrollBar"
Value="{TemplateBinding VerticalOffset}"
Maximum="{TemplateBinding ScrollableHeight}"
ViewportSize="{TemplateBinding ViewportHeight}"
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"/>
<ScrollBar Name="PART_HorizontalScrollBar"
Orientation="Horizontal"
Grid.Row="1"
Grid.Column="1"
Value="{TemplateBinding HorizontalOffset}"
Maximum="{TemplateBinding ScrollableWidth}"
ViewportSize="{TemplateBinding ViewportWidth}"
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
將此風格ScrolViewer
<ScrollViewer Grid.Column="1" Style="{StaticResource LeftScrollViewer}">
這個樣本不會在Windows Phone的,因爲這的ScrollViewer控件模板從descktop WPF工作。但是你可以使用Expression Blend和獲得的Windows Phone ScrolViewer的ControlTemplate和Visibility="Visible"
1
改變類似
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"/>
你可以用一個始終顯示滾動條替換默認的ScrollViewer模板。請注意,這與windows手機設計指南不一致,您應該在選擇始終顯示滾動條之前仔細思考。
<phone:PhoneApplicationPage.Resources>
<Style x:Key="ScrollViewerStyle1" TargetType="ScrollViewer">
<Setter Property="VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ScrollViewer">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ScrollStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="00:00:00.5"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="Scrolling">
<Storyboard>
<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="VerticalScrollBar"/>
<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HorizontalScrollBar"/>
</Storyboard>
</VisualState>
<VisualState x:Name="NotScrolling"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid Margin="{TemplateBinding Padding}">
<ScrollContentPresenter x:Name="ScrollContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}"/>
<ScrollBar x:Name="VerticalScrollBar" HorizontalAlignment="Right" Height="Auto" IsHitTestVisible="False" IsTabStop="False" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Opacity="1" Orientation="Vertical" Visibility="Visible" Value="{TemplateBinding VerticalOffset}" ViewportSize="{TemplateBinding ViewportHeight}" VerticalAlignment="Stretch" Width="5"/>
<ScrollBar x:Name="HorizontalScrollBar" HorizontalAlignment="Stretch" Height="5" IsHitTestVisible="False" IsTabStop="False" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Opacity="0" Orientation="Horizontal" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{TemplateBinding HorizontalOffset}" ViewportSize="{TemplateBinding ViewportWidth}" VerticalAlignment="Bottom" Width="Auto"/>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</phone:PhoneApplicationPage.Resources>
<ScrollViewer Style="{StaticResource ScrollViewerStyle1}">
相關問題
- 1. Windows Phone 7中的ScrollViewer
- 2. Windows phone 7 scrollviewer問題
- 3. windows phone 7的邊框
- 4. Windows phone 7按鈕「邊框」
- 5. Windows Phone 7 - ScrollViewer值已更改
- 6. Windows Phone 8 ScrollViewer
- 7. 畫布邊框c#(Windows Phone 7)
- 8. windows phone scrollviewer jump effect
- 9. Windows Phone 7 XNA GUI框架
- 10. Windows Phone 7列表框
- 11. Windows Phone 7對話框
- 12. Windows Phone 8的ScrollViewer事件
- 13. ScrollViewer不滾動Windows Phone 8
- 14. GestureListener在ScrollViewer中的Windows Phone 7上不起作用
- 15. 在Windows Phone 7中查看scrollviewer的隱藏部分
- 16. MediaElement Windows Phone 7
- 17. Windows Phone 7:SQLite
- 18. Windows Phone 7 - WebBrowserTask
- 19. WCF + Windows Phone 7
- 20. Windows Phone 7 textBox
- 21. Windows Phone 7 onDraw
- 22. IsolatedStorage @Windows Phone 7
- 23. Windows Phone 7-System.ArgumentOutOfRangeException
- 24. Azure + Windows phone 7
- 25. Windows Phone 7 SaveContactTask
- 26. XmlConvert.ToDateTime Windows Phone 7
- 27. 爲Windows Phone 7
- 28. Windows Phone 7 longlistselector
- 29. windows phone 7 appstore?
- 30. Windows 7 PHONE - KeyNotFoundException