Tôi có một webscrollview trong WP7, mà ban đầu không có tập trung (nội dung là hittestVisible, do đó lấy đi các scrollviewers hittestvisibility). Khi tôi đặt hiển thị nội dung của nó thành false, tôi có thể cuộn scrollviewer, nhưng chỉ sau khi nhấc ngón tay của tôi, và đặt nó trở lại một lần nữa. Tôi thực sự muốn tập trung để thay đổi, và sau này áp dụng lại tiêu điểm để tôi có thể trượt sau khi scrollview đạt được tiêu điểm, không chờ đợi cho sự kiện manipulationStarted tiếp theo để bắn. Đây là mã của tôi:Fire ManipulationStarted thủ công trong WP7
<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>
trong 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;
}
Các TouchFrameDeltais một sự kiện Touch.FrameReported. Có ai có ý tưởng không biết tại sao điều này không hiệu quả và cách khắc phục? Cảm ơn trước
Để làm rõ, mục tiêu cuối cùng là có bảng điều khiển cuộn ngang, với nội dung là ba điều khiển người dùng được xếp chồng lên nhau theo chiều ngang? Nếu vậy, hành vi scrollviewer mặc định sẽ không hoạt động cho điều này (thiết lập IsHitTestVisible trên scrollviewer trở lại đúng)? – codechinchilla
Vấn đề là, khi tôi đặt IsHitTestVisible hoặc bất kỳ thay đổi bố cục nhập người dùng nào khác, được xử lý sau khi người dùng phát hành và thay thế ngón tay của họ. Điều này có cái gì đó để làm với sự kiện bắt đầu thao tác, tôi đoán. Khi trình duyệt tuyên bố tính hittestvisibility, thao tác bắt đầu của scrollviewer không được kích hoạt, và chỉ trong sự kiện thao tác tiếp theo sẽ bắt và xử lý nó. Vì vậy, ngay cả khi tôi cuộn theo chiều ngang, cập nhật bố cục, thực hiện tất cả các thứ cập nhật lạ, trình duyệt vẫn còn hittestvisible và vẫn như vậy cho đến khi tôi phát hành và đăng ký lại – GeekPeek
Có thể cung cấp xaml thực tế mà bạn đang sử dụng cho trang không? Bằng cách đó, chúng tôi có thể cố gắng tái tạo vấn đề chính xác hơn. – codechinchilla