Flyout.showAt()基于内容的ArgumentException [英] Flyout.showAt() ArgumentException based on Content
本文介绍了Flyout.showAt()基于内容的ArgumentException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图以这种方式使用Flyout。
this.DefaultViewModel [SelectedVideo] = vi;
Flyout f = new Flyout();
f.Content = this.videoFlyoutContent;
f.ShowAt(videosGrid); //我有一个例外
而我有以下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 =WordEllipsisFontSize =16FontWeight =SemiBoldTextWrapping =Wrap
Style ={StaticResource UNIListItemStyle_TitleTextBlock}HorizontalAlignment =CenterWidth ={StaticResource FlyoutTextWidth}
Foreground ={StaticResource VideoElement_TextForeground}/>
< / Grid>
< / ContentControl>
< /Page.Resources>现在,问题是我在f.showAt()中得到一个ArgumentException; System.ArgumentException:值不在预期范围内。
在Windows.UI.Xaml.Controls.Primitives.FlyoutBase.ShowAt(FrameworkElement placementTarget)
f.Content = this.videoFlyoutContent;
解决方案只需使用:
< Page.Resources>
< Flyout x:Name =myFlyout>
< Grid> ...< / Grid>
< / Flyout>
< /Page.Resources>
和
myFlyout.showAt(videosGrid);
但不知道为什么它没有以其他方式工作。
I am trying to use a Flyout this way
this.DefaultViewModel["SelectedVideo"] = vi;
Flyout f = new Flyout();
f.Content = this.videoFlyoutContent;
f.ShowAt(videosGrid); // HERE I GET AN EXCEPTION
while I have the following XAML code
<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>
Now, the problem is that I get an ArgumentException in f.showAt();
System.ArgumentException: Value does not fall within the expected range.
at Windows.UI.Xaml.Controls.Primitives.FlyoutBase.ShowAt(FrameworkElement placementTarget)
which is not raised if I remove the line
f.Content = this.videoFlyoutContent;
解决方案 Solved simply by using:
<Page.Resources>
<Flyout x:Name="myFlyout">
<Grid>...</Grid>
</Flyout>
</Page.Resources>
and
myFlyout.showAt(videosGrid);
but no idea of why it didn't work the other way.
这篇关于Flyout.showAt()基于内容的ArgumentException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文