我对flipview有一个非常奇怪的行为(赢得8.1 xaml for windows phone)
<FlipView Name="flip" ItemTemplate="{StaticResource DataTemplate1}" Loaded="flip_Loaded">
<FlipView.Resources>
<Style x:Key="FlipViewStyle1" TargetType="FlipView">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="TabNavigation" Value="Once"/>
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden"/>
<Setter Property="ScrollViewer.IsHorizontalRailEnabled" Value="False"/>
<Setter Property="ScrollViewer.IsVerticalRailEnabled" Value="False"/>
<Setter Property="ScrollViewer.IsHorizontalScrollChainingEnabled" Value="True"/>
<Setter Property="ScrollViewer.IsVerticalScrollChainingEnabled" Value="True"/>
<Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False"/>
<Setter Property="ScrollViewer.BringIntoViewOnFocusChange" Value="True"/>
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<VirtualizingStackPanel AreScrollSnapPointsRegular="True"
Orientation="Horizontal"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="FlipView">
<Grid>
<Border BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}">
<Grid>
<ScrollViewer x:Name="ScrollingHost"
AutomationProperties.AccessibilityView="Raw"
BringIntoViewOnFocusChange="{TemplateBinding ScrollViewer.BringIntoViewOnFocusChange}"
HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
HorizontalSnapPointsType="MandatorySingle"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
IsTabStop="False"
IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
IsHorizontalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsHorizontalScrollChainingEnabled}"
IsVerticalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsVerticalScrollChainingEnabled}"
IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
Padding="{TemplateBinding Padding}"
TabNavigation="{TemplateBinding TabNavigation}"
VerticalSnapPointsType="MandatorySingle"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
ZoomMode="Disabled">
<ItemsPresenter/>
</ScrollViewer>
</Grid>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</FlipView.Resources>
<FlipView.Style>
<StaticResource ResourceKey="FlipViewStyle1"/>
</FlipView.Style>
</FlipView>
和datatemplate:
<DataTemplate x:Key="DataTemplate1">
<Grid>
<Image Stretch="Uniform" Source="{Binding image}" />
</Grid>
</DataTemplate>
我在“已加载的事件”中设置了itemsource
private void flip_Loaded(object sender, RoutedEventArgs e)
{
flip.ItemsSource = _vm.Profile.photos;
}
其中photos是包含来自web的图像的字符串链接的自定义类的列表。列表中约有30个项目。
一切都很简单,工作得很好直到我快速随机地向后滑动翻转视图。 我得到一个未处理的例外情况&#34;价值不会落在预期范围内&#34;没有堆栈跟踪。
这可能是完全随机的,可能不会。有人请指导我一个解决方法。这让我疯狂:(
更多代码:
在上一页中,我有一个完美的网格视图。在点击特定缩略图时:
private void GridView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if ((sender as GridView).SelectedIndex != -1)
{
DispatcherHelper.CheckBeginInvokeOnUI(() =>
Frame.Navigate(typeof(InstaPhotoView), new InstaProfilePlusSelection()
{
Profile = ViewModel.InstaProfile,
SelectedIndex = (sender as GridView).SelectedIndex
}));
(sender as GridView).SelectedIndex = -1;
}
}
在我有
的InstaPhotoView页面中InstaProfilePlusSelection _vm = new InstaProfilePlusSelection();
public InstaPhotoView()
{
this.InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
HardwareButtons.BackPressed += HardwareButtons_BackPressed;
if (e.Parameter != null)
_vm = e.Parameter as InstaProfilePlusSelection;
}
加上当然加载的事件在上面给出
答案 0 :(得分:1)
尝试更新数据模板。如果您知道显示图像的widnow的最大宽度或高度,请设置SELECT DISTINCT j.BatchId AS CompletedJobs
FROM Job j
LEFT JOIN
--running jobs or jobs who ran into an error:
(SELECT j2.BatchId
FROM Job j2
WHERE j2.JobStatusId IN (1,2)) j2 ON j.BatchId = j2.BatchId
WHERE j2.BatchId IS NULL
或DecodePixelHeight
。这将提高应用程序性能。
DecodePixelWidth
还可以尝试设置<DataTemplate x:Key="DataTemplate1">
<Image Stretch="Uniform">
<Image.Source>
<BitmapImage UriSource="{Binding image}" DecodePixelHeight="250" />
</Image.Source>
</Image>
</DataTemplate>
属性。我现在没有安装VS.
答案 1 :(得分:0)
最终放弃了flipview。 Microsoft必须在控件中存在一些潜在问题。以下是使用ListView模仿flipview的方法:
<ListView Name="flip" SelectionMode="None" ItemsSource="{Binding Profile.photos}" Loaded="flip_Loaded">
<ListView.Resources>
<Style x:Key="ListViewStyle1" TargetType="ListView">
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="TabNavigation" Value="Once"/>
<Setter Property="IsSwipeEnabled" Value="True"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Top"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Visible"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/>
<Setter Property="ScrollViewer.HorizontalScrollMode" Value="Auto"/>
<Setter Property="ScrollViewer.VerticalScrollMode" Value="Disabled"/>
<Setter Property="ScrollViewer.ZoomMode" Value="Disabled"/>
<Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False"/>
<Setter Property="ScrollViewer.BringIntoViewOnFocusChange" Value="True"/>
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<ItemsStackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListView">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
<ScrollViewer x:Name="ScrollViewer" AutomationProperties.AccessibilityView="Raw" BringIntoViewOnFocusChange="{TemplateBinding ScrollViewer.BringIntoViewOnFocusChange}" HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}" IsHorizontalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsHorizontalScrollChainingEnabled}" IsVerticalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsVerticalScrollChainingEnabled}" IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}" IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}" TabNavigation="{TemplateBinding TabNavigation}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}" ZoomMode="{TemplateBinding ScrollViewer.ZoomMode}" HorizontalSnapPointsType="MandatorySingle">
<ItemsPresenter FooterTransitions="{TemplateBinding FooterTransitions}" FooterTemplate="{TemplateBinding FooterTemplate}" Footer="{TemplateBinding Footer}" HeaderTemplate="{TemplateBinding HeaderTemplate}" Header="{TemplateBinding Header}" HeaderTransitions="{TemplateBinding HeaderTransitions}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.Resources>
<ListView.Style>
<StaticResource ResourceKey="ListViewStyle1"/>
</ListView.Style>
<ListView.ItemTemplate>
<DataTemplate>
<Grid Width="{Binding ElementName=root,Path=ActualWidth}" Height="{Binding ElementName=root,Path=ActualHeight}">
<Image Stretch="Uniform">
<Image.Source>
<BitmapImage UriSource="{Binding image}" DecodePixelWidth="250" DecodePixelHeight="250" />
</Image.Source>
</Image>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
注意网格的高度和高度。 datatemplate中的width绑定到页面的根元素(在我的例子中是一个Grid)。此外,还修改了滚动查看器以启用捕捉点,并且itemsstackpanel的方向是水平的。