在我的 WindowsPhone 应用程序中使用 FlipView 时遇到问题。我有一个带有 FlipView 的页面,它具有绑定到 ItemsGroup 的 ItemsSource 和绑定到 CurrentItem 的 SelectedItem。FlipView 的 DataTemplate 包括 WebView,它具有绑定到 CurrentItem 的 Html 的附加属性 Html。一切顺利,但应用程序不时因 System.ArgumentException 而崩溃,我不知道出了什么问题。
XAML:
<Page
x:Class="UkraineNews.ItemPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:common="using:News.Common"
xmlns:viewModel="using:News.ViewModel"
xmlns:converter="using:News.Converter">
<Page.DataContext>
<viewModel:PhoneGroupViewModel/>
</Page.DataContext>
<Page.Resources>
<converter:DateConverter x:Key="DateConverter"
IsShowFullDate="True"/>
</Page.Resources>
<Grid>
<FlipView ItemsSource="{Binding Group.Items}"
SelectedItem="{Binding Group.CurrentItem, Mode=TwoWay}">
<FlipView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border Grid.Row="0"
Background="{StaticResource ItemBorderBackground}"
HorizontalAlignment="Right"
Padding="5"
CornerRadius="0,0,0,5">
<TextBlock Text="{Binding Published, Converter={StaticResource DateConverter}}"/>
</Border>
<TextBlock Grid.Row="1"
TextWrapping="Wrap"
Text="{Binding Title}"
FontWeight="Bold"
Margin="24,0"
FontSize="20"
Foreground="{StaticResource LeftMenuBackgroundBrush}"/>
<WebView Grid.Row="2"
NavigationStarting="WebView_NavigationStarting"
common:WebViewBehaviour.Html="{Binding Html}"/>
</Grid>
</DataTemplate>
</FlipView.ItemTemplate>
</FlipView>
</Grid>
C#:
public class NewsItem
{
public string Title { get; set; }
public string Link { get; set; }
public DateTime Published { get; set; }
public string Html { get; set; }
public string Image { get; set; }
}
错误:
参数不正确。System.ArgumentException:值不在预期范围内。