代码之家  ›  专栏  ›  技术社区  ›  Madeleine

Silverlight-从页面中取出嵌入的自定义控件并使其全屏显示

  •  0
  • Madeleine  · 技术社区  · 14 年前

    我有一个Silverlight 4应用程序。应用程序的RootVisual主页上有许多控件,其中一个是名为VideoPlayerView的用户控件。我希望当用户单击此控件上的全屏图标时,此控件才能“弹出”页面并全屏显示(即,此页上的所有其他控件都必须隐藏,并且只有VideoPlayerView控件才会全屏显示)。

    主页面的行和列定义设置如下:

    <Grid.ColumnDefinitions>
            <ColumnDefinition Width="143"/>
            <ColumnDefinition Width="4"/>
            <ColumnDefinition Width="81"/>
            <ColumnDefinition Width="27"/>
            <ColumnDefinition Width="624"/>
            <ColumnDefinition Width="125"/>
            <ColumnDefinition Width="10"/>
            <ColumnDefinition Width="10"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="15"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="10"/>
            <RowDefinition Height="21"/>
            <RowDefinition Height="10"/>
            <RowDefinition Height="199"/>
            <RowDefinition Height="220"/>
            <RowDefinition Height="21"/>
            <RowDefinition Height="160"/>
            <RowDefinition Height="26"/>
            <RowDefinition Height="45"/>
        </Grid.RowDefinitions>
    

    我尝试从当前父控件中删除VideoPlayerView控件,清除MainPage.LayoutRoot的子集合,并将VideoPlayerView添加到MainPage的LayoutRoot中,但由于某些原因,VideoPlayerView只显示在屏幕的前1/4处。

    如果有人知道怎么做请告诉我!

    2 回复  |  直到 14 年前
        1
  •  0
  •   Murven    14 年前

    视频播放器之所以只占屏幕的四分之一,可能是因为它默认添加到网格的第一行和第一列。如果希望它跨越多行和多列,则必须使用Grid.ColumnSpan=8和Grid.RowSpan=11,以便它填充整个屏幕。

    此外,您不必严格地从子集合中移除所有控件;将它们的可见性转换为折叠就足够了。

    VisualStateManager.GoToState(this, "Normal", true);
    

    以及:

    VisualStateManager.GoToState(this, "Fullscreen", true);
    
        2
  •  0
  •   Madeleine    14 年前

    问题出在我们的XAML中-视频播放器视图上设置了Clip属性,该属性在全屏模式下关闭视频。在全屏模式下删除此属性解决了问题。