C# Windows Phone 8.1操作事件不触发
我试图在ListView上使用Windows Phone 8.1上的操纵事件,但没有触发任何操纵事件。指针事件触发,但它们的工作方式非常奇怪,我需要操纵事件。即使我尝试在父元素上触发事件,也不会触发任何事件。我找到了一个可以满足我需要的软件,但是它在WindowsPhone8.1上不起作用。还有一个人似乎也有同样的问题,有人说他们添加的事件很好(不过没有代码片段)。我尝试将事件添加到父元素,但没有触发任何事件,我尝试使用ListView的ScrollViewer并将事件添加到其中,但没有触发任何事件,我甚至尝试将ListView更改为ListBox,但仍然没有触发任何事件。任何帮助都将不胜感激C# Windows Phone 8.1操作事件不触发,c#,xaml,event-handling,windows-phone-8.1,C#,Xaml,Event Handling,Windows Phone 8.1,我试图在ListView上使用Windows Phone 8.1上的操纵事件,但没有触发任何操纵事件。指针事件触发,但它们的工作方式非常奇怪,我需要操纵事件。即使我尝试在父元素上触发事件,也不会触发任何事件。我找到了一个可以满足我需要的软件,但是它在WindowsPhone8.1上不起作用。还有一个人似乎也有同样的问题,有人说他们添加的事件很好(不过没有代码片段)。我尝试将事件添加到父元素,但没有触发任何事件,我尝试使用ListView的ScrollViewer并将事件添加到其中,但没有触发任何
public MainPage()
{
this.InitializeComponent();
this.NavigationCacheMode = NavigationCacheMode.Required;
ItemLV.DataContext = Items.DealsCollection;
ItemLV.ManipulationStarted += ItemLV_ManipulationStarted;
}
private void ItemLV_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
{
throw new NotImplementedException();
}
<Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Pivot Grid.Row="1" x:Name="Pivot">
<PivotItem Margin="0,-5,0,0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="frontpage" Foreground="#0072bc" FontSize="30" Margin="5,0,0,0"/>
<ListView x:Name="ItemLV" IsItemClickEnabled="True" Grid.Row="1" ItemsSource="{Binding}">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel></StackPanel>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate>
<Grid x:Name="ItemGrid" Margin="0,2,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="110"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Image Source="{Binding ImgUrl}" Stretch="Uniform" Canvas.ZIndex="2" Margin="5,5,5,2" VerticalAlignment="Center"/>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding Title}"
VerticalAlignment="Center" HorizontalAlignment="Left"
FontSize="18" TextWrapping="Wrap" Foreground="Black"/>
<StackPanel Orientation="Horizontal" Grid.Row="1">
<TextBlock Text="{Binding Price}"
VerticalAlignment="Center" HorizontalAlignment="Left"
FontSize="20" TextWrapping="Wrap" Foreground="#0075DB"/>
<Image Source="Assets/flame.gif" Visibility="{Binding Firedeal, Converter={StaticResource ImageBoolConverter}}" VerticalAlignment="Center" Margin="5,3,0,0"/>
</StackPanel>
<TextBlock Text="{Binding ExtraInfo}" Grid.Row="2"
VerticalAlignment="Center" HorizontalAlignment="Left"
FontSize="16" TextWrapping="Wrap" Foreground="#569B1A"
Visibility="{Binding ExtraInfo, Converter={StaticResource LengthConverter}}">
</TextBlock>
<Grid Grid.Row="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Store}"
VerticalAlignment="Bottom" HorizontalAlignment="Left"
FontSize="16" TextWrapping="Wrap" Foreground="#666"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Column="1">
<TextBlock Text="{Binding Rating}" VerticalAlignment="Bottom"
FontSize="16" TextWrapping="Wrap" Foreground="Black"/>
<Image Source="Assets/tup.png" VerticalAlignment="Bottom" Margin="2,0,5,0" />
<TextBlock Text="{Binding Comments}" VerticalAlignment="Bottom"
FontSize="16" TextWrapping="Wrap" Foreground="Black"/>
<Image Source="Assets/comment.png" VerticalAlignment="Bottom" Margin="0,4,3,0" />
</StackPanel>
</Grid>
</Grid>
<Border BorderThickness="0,2,0,0" BorderBrush="#0072bc" Grid.ColumnSpan="2"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</PivotItem>
</Pivot>
</Grid>
public主页()
{
this.InitializeComponent();
this.NavigationCacheMode=NavigationCacheMode.Required;
ItemLV.DataContext=Items.DealsCollection;
ItemLV.ManipulationStarted+=ItemLV_ManipulationStarted;
}
私有void ItemLV_操纵已启动(对象发送方,操纵已启动RoutedEventArgs e)
{
抛出新的NotImplementedException();
}
试试这个
public MainPage()
{
this.InitializeComponent();
this.ItemLV.AddHandler(UIElement.ManipulationStartedEvent,new ManipulationStartedEventHandler(ItemLV_ManipulationStarted), true);
}
尝试此链接您将不会获得操纵事件,因为ListView已将其设置为System。根据: 元素必须具有除None或System之外的OperationMode值才能作为操纵事件源
我不建议更改模式,因为它很可能会停止滚动。您找到解决方案了吗?对于
operationcompleted
我必须使用此选项:control.AddHandler(System.Windows.UIElement.operationcompletedevent,new EventHandler(control\u operationcompleted),true)代码>