I have a webscrollview in WP7, which initially does not have focus ( the content is hittestVisible, therefore takes away the scrollviewers hittestvisibility ). When I set its content's visibility to false, I can scroll the scrollviewer, but only after lifting my finger, and placing it back again. I would really like the focus to shift, and after this re-apply the focus so that I can slide after the scrollview gains focus, not wait for the next manipulationStarted event to fire. Here is my code:
<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>
in 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;
}
The TouchFrameDeltais a Touch.FrameReported event. Does anyone have a n idea why this does not work, and how to fix it? Thanks in advance
Just to clarify for you, ManipulationStarted
(and Completed) cannot be fired manually, as their EventArgs are sealed without any public constructors.
What you're asking for, isn't something I would consider possible. Since your child item doesn't support any interaction initially, the events wouldn't be bubbled down to it, even after you set IsHitTestVisible
before you performed yet another event.
I can't see what you're exactly trying to archive here, but messing with scrolling and the WebBrowser is not something I would recommend for 7.0/7.5, as the control have very limited functionality.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With