WPF中的Jquery轮播
我想像这里一样在WPF中创建轮播。 (左右按钮不计算,只是子弹)
我找到了很多解决方案如何在WPF中创建轮播,但它并不是我需要的。 我有listBox图像:
和滑块子弹:
我不知道如何在它们之间创建“关系” – 当我点击子弹时,应该显示具有相同索引的图像。
简单的XAML。 我在评论中的意思是:
图像 – 我们可以在哪里看到我们的图像。 ListBox – 我们的子弹。 我不删除选择边框,但它只是一个示例。
图像绑定到SelectedItem.Image属性,因此我们的上下文必须是具有此属性的内容。
关于操纵。 我正在使用ListCollectionView作为DataContext和OnManipulationCompleted事件。
private ListCollectionView Context { get; } private void UIElement_OnManipulationCompleted(object sender, ManipulationCompletedEventArgs e) { if (e.TotalManipulation.Translation.X < 5) { if (Context.CurrentPosition == 0) Context.MoveCurrentToLast(); else Context.MoveCurrentToPrevious(); e.Handled = true; } else if (e.TotalManipulation.Translation.X > 5) { if (Context.CurrentPosition == Context.Count) Context.MoveCurrentToFirst(); else Context.MoveCurrentToNext(); e.Handled = true; } }
正如我测试的那样,它的工作非常完美。