【发布时间】:2014-05-12 18:45:44
【问题描述】:
我正在尝试以这种方式使用 Flyout
this.DefaultViewModel["SelectedVideo"] = vi;
Flyout f = new Flyout();
f.Content = this.videoFlyoutContent;
f.ShowAt(videosGrid); // HERE I GET AN EXCEPTION
虽然我有以下 XAML 代码
<Page.Resource>
<!-- ................ -->
<!-- ................ -->
<x:Double x:Key="FlyoutWidth">500</x:Double>
<x:Double x:Key="FlyoutHeight">440</x:Double>
<x:Double x:Key="FlyoutTextWidth">400</x:Double>
<ContentControl x:Name="videoFlyoutContent">
<Grid DataContext="{Binding SelectedVideo}" Width="{StaticResource FlyoutWidth}" Height="{StaticResource FlyoutHeight}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Source="{Binding thumbnail.hqDefault}" /> <!-- 480x360 -->
<TextBlock Grid.Row="1"
Text="{Binding Title}" TextTrimming="WordEllipsis" FontSize="16" FontWeight="SemiBold" TextWrapping="Wrap"
Style="{StaticResource UNIListItemStyle_TitleTextBlock}" HorizontalAlignment="Center" Width="{StaticResource FlyoutTextWidth}"
Foreground="{StaticResource VideoElement_TextForeground}"/>
</Grid>
</ContentControl>
</Page.Resources>
现在,问题是我在 f.showAt(); 中得到一个 ArgumentException;
System.ArgumentException: Value does not fall within the expected range.
at Windows.UI.Xaml.Controls.Primitives.FlyoutBase.ShowAt(FrameworkElement placementTarget)
如果我删除该行,则不会引发
f.Content = this.videoFlyoutContent;
【问题讨论】:
-
如果“videoFlyoutContent”是一个空网格,也会发生同样的情况。
标签: c# windows-store-apps winrt-xaml windows-8.1