我在WP7中有一个webscrollview,它最初没有焦点(内容是hittestVisible,因此带走了scrollviewers hittestvisibility).当我将其内容的可见性设置为false时,我可以滚动滚动查看器,但只有在抬起我的手指并将其再次放回之后.我真的希望焦点转移,然后重新应用焦点,以便我可以在scrollview获得焦点后滑动,而不是等待下一个manipStarted事件触发.这是我的代码:
<UserControl
x:Class="WTFApp.Resources.ViewControllers.DetailedItemContentControl"
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"
xmlns:local="clr-namespace:EiBaseApi.Animation;assembly=EiBaseApi"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
shell:SystemTray.IsVisible="True" >
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.Resources>
<Storyboard x:Name="MediatedListBoxContentAnimator">
<DoubleAnimation x:Name="MediatedAnimation"
Storyboard.TargetName="WebScrollViewMediator"
Storyboard.TargetProperty="ScrollableWidthMultiplier" >
</DoubleAnimation>
</Storyboard>
</Grid.Resources>
<ScrollViewer x:Name="Scroller"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Disabled"
ManipulationMode="Control"
Grid.Row="1"
Grid.RowSpan="2" >
<StackPanel Name="WebScrollView" Orientation="Horizontal">
<UserControl Name="LeftContentControl" MinWidth="480" />
<UserControl Name="MiddleContentControl" MinWidth="480" />
<UserControl Name="RightContentControl" MinWidth="480" />
</StackPanel>
</ScrollViewer>
<local:ScrollableItemAnimationMediator x:Name="WebScrollViewMediator"
ScrollViewer="{Binding ElementName=Scroller}"/>
</Grid>
Run Code Online (Sandbox Code Playgroud)
在C#中:
protected override void TouchFrameDelta( object sender, TouchFrameEventArgs e )
{
if ( UserManipulating == ManipulationState.ManipulationStopped )
{
UserManipulating = ManipulationState.ManipulationStarted;
ManipulationStartingPoint = e.GetPrimaryTouchPoint( null ).Position;
}
//if we are already manipulating the scrollviewer, we do nothing
if ( UserManipulating != ManipulationState.ManipulationStarted )
{
return;
}
TouchPoint touchPoint = e.GetPrimaryTouchPoint( null );
float differenceStart = ( float )( touchPoint.Position.X - ManipulationStartingPoint.X );
if ( Math.Abs( differenceStart ) >= 25 )
{
if ( BrowserListIsHitTestVisible )
{
BrowserListIsHitTestVisible = false;
MiddleContentControl.Focus( );
MiddleContentControl.UpdateLayout( );
return;
}
float differenceDelta = ( float ) ( touchPoint.Position.X - ManipulationDeltaPoint.X );
if ( touchPoint.Action == TouchAction.Up )
{
UserManipulating = ManipulationState.ManipilatingScrollViewCompleted;
OnManipulationCompleted( differenceDelta );
}
}
ManipulationDeltaPoint = touchPoint.Position;
}
Run Code Online (Sandbox Code Playgroud)
TouchFrameDelta是一个Touch.FrameReported事件.有谁知道为什么这不起作用,以及如何解决它?提前致谢
只是为了向您澄清,ManipulationStarted
(和 Completed)不能手动触发,因为它们的 EventArgs 是密封的,没有任何公共构造函数。
你所要求的,我认为是不可能的。IsHitTestVisible
由于您的子项目最初不支持任何交互,因此即使您在执行另一个事件之前进行设置,事件也不会冒泡到它。
我看不出你到底想在这里存档什么,但我不建议在 7.0/7.5 中混用滚动和 WebBrowser,因为该控件的功能非常有限。
归档时间: |
|
查看次数: |
722 次 |
最近记录: |