سؤال

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top