JumpList 在 ScrollTo 上崩溃
JumpList crash on ScrollTo
我问一个问题是因为当我尝试使用我的跳转列表时我的应用程序崩溃了。
列表填写正确,但当我尝试跳跃时,我遇到了
e.ExceptionObject {System.ArgumentException: The provided item doesn't exist in the collection.
at Microsoft.Phone.Controls.LongListSelector.ScrollTo(Object item, Nullable1 isGroup, Boolean containerViewport, Boolean setUiaFocus)
at Microsoft.Phone.Controls.LongListSelector.OnJumpListClosing(Object item)
at Microsoft.Phone.Controls.JumpListController.BeginHide(Object selectedItem)
at Microsoft.Phone.Controls.JumpListController.OnSelectionChanged(Object sender, SelectionChangedEventArgs e)
at Microsoft.Phone.Controls.LongListSelector.set_SelectedItem(Object value)
at Microsoft.Phone.Controls.LongListSelector.OnItemTap(Object sender, GestureEventArgs e)
at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)} System.Exception {System.ArgumentException}
编辑:一些 XAML
<phone:LongListSelector Name="ListCategorie" Margin="13,-30,0,0"
ItemsSource="{Binding GroupedInformation}"
ItemTemplate="{StaticResource orderByCategorieItemTemplate}"
GroupHeaderTemplate="{StaticResource orderByCategorieGroupHeader}"
JumpListStyle="{StaticResource orderByCategorieJumpListStyle}"
IsGroupingEnabled="True"
LayoutMode="List"
GridCellSize="480,62"
SelectionChanged="ListCategorie_SelectionChanged"
/>
和 jumpListStyle
<Style x:Key="orderByCategorieJumpListStyle"
TargetType="phone:LongListSelector">
<Setter Property="LayoutMode"
Value="List" />
<Setter Property="Margin"
Value="12,12,0,0"/>
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<Border Background="{Binding Key,Converter={StaticResource FormatConverter}}"
Width="470"
Height="70"
Margin="6">
<TextBlock Text="{Binding Key}"
Foreground="{Binding Converter={StaticResource ForegroundConverter}}"
FontFamily="{StaticResource PhoneFontFamilySemiLight}"
FontSize="28"
Padding="2"
VerticalAlignment="Bottom"/>
</Border>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
以及列表的创建
public List<KeyedList<string, Information>> GroupedInformation
{
get
{
var infs= Information.loadXml();
infs= Information.orderByCategorie(infs);
var GroupedInformation=
from inf in infs
group inf by inf.categorie into infByCat
select new KeyedList<string, Information>(infByCat);
return new List<KeyedList<string, Information>>(infs);
}
}
我找到了解决方案,我有一个在大小改变时刷新列表的功能,所以当我转到 jumpListSelection 时,应用程序刷新列表,这就是它找到项目的原因
抱歉给您带来不便
我问一个问题是因为当我尝试使用我的跳转列表时我的应用程序崩溃了。 列表填写正确,但当我尝试跳跃时,我遇到了
e.ExceptionObject {System.ArgumentException: The provided item doesn't exist in the collection.
at Microsoft.Phone.Controls.LongListSelector.ScrollTo(Object item, Nullable1 isGroup, Boolean containerViewport, Boolean setUiaFocus)
at Microsoft.Phone.Controls.LongListSelector.OnJumpListClosing(Object item)
at Microsoft.Phone.Controls.JumpListController.BeginHide(Object selectedItem)
at Microsoft.Phone.Controls.JumpListController.OnSelectionChanged(Object sender, SelectionChangedEventArgs e)
at Microsoft.Phone.Controls.LongListSelector.set_SelectedItem(Object value)
at Microsoft.Phone.Controls.LongListSelector.OnItemTap(Object sender, GestureEventArgs e)
at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)} System.Exception {System.ArgumentException}
编辑:一些 XAML
<phone:LongListSelector Name="ListCategorie" Margin="13,-30,0,0"
ItemsSource="{Binding GroupedInformation}"
ItemTemplate="{StaticResource orderByCategorieItemTemplate}"
GroupHeaderTemplate="{StaticResource orderByCategorieGroupHeader}"
JumpListStyle="{StaticResource orderByCategorieJumpListStyle}"
IsGroupingEnabled="True"
LayoutMode="List"
GridCellSize="480,62"
SelectionChanged="ListCategorie_SelectionChanged"
/>
和 jumpListStyle
<Style x:Key="orderByCategorieJumpListStyle"
TargetType="phone:LongListSelector">
<Setter Property="LayoutMode"
Value="List" />
<Setter Property="Margin"
Value="12,12,0,0"/>
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<Border Background="{Binding Key,Converter={StaticResource FormatConverter}}"
Width="470"
Height="70"
Margin="6">
<TextBlock Text="{Binding Key}"
Foreground="{Binding Converter={StaticResource ForegroundConverter}}"
FontFamily="{StaticResource PhoneFontFamilySemiLight}"
FontSize="28"
Padding="2"
VerticalAlignment="Bottom"/>
</Border>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
以及列表的创建
public List<KeyedList<string, Information>> GroupedInformation
{
get
{
var infs= Information.loadXml();
infs= Information.orderByCategorie(infs);
var GroupedInformation=
from inf in infs
group inf by inf.categorie into infByCat
select new KeyedList<string, Information>(infByCat);
return new List<KeyedList<string, Information>>(infs);
}
}
我找到了解决方案,我有一个在大小改变时刷新列表的功能,所以当我转到 jumpListSelection 时,应用程序刷新列表,这就是它找到项目的原因 抱歉给您带来不便