【发布时间】:2017-03-19 04:16:29
【问题描述】:
我有一个弹出窗口,打开时会填满整个页面。
<Grid x:Name="gridRoot" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Button Content="Open" HorizontalAlignment="Center" Click="{x:Bind viewModel.OpenPopup}" />
<Popup x:Name="popupCorrect" VerticalAlignment="Top" IsOpen="{Binding IsOpen}" IsLightDismissEnabled="False">
<Popup.ChildTransitions>
<TransitionCollection>
<PaneThemeTransition Edge="Left" />
</TransitionCollection>
</Popup.ChildTransitions>
<uc:MyPopup Width="{Binding ElementName=gridRoot, Path=ActualWidth}" Height="{Binding ElementName=gridRoot, Path=ActualHeight}"/>
</Popup>
</Grid>
弹出窗口是一个用户控件
<Grid Background="Red">
<Button Content="Close" HorizontalAlignment="Center" Click="{x:Bind viewModel.ClosePopup}" />
</Grid>
- 页面
- 显示弹出窗口时
- 关闭弹出窗口,调整页面大小,然后重新打开弹出窗口。请注意,即使它的
Width和Height绑定到gridRoot,它也不匹配容器页面的新大小。我是否必须为弹出窗口手动设置新的Width和Height?为什么我不能通过绑定来实现这一点?在“OrientationChanged”期间,此问题也出现在移动设备上
【问题讨论】:
-
可以使用鼠标位置吗?
-
你能详细说明吗?
-
将
ActualWidth设置为绑定源通常不会按预期工作。请参阅this 了解更多信息。 -
在您的应用程序的上下文中,您可以使用
Flyout并设置PlacementMode=Full属性吗? -
@Lindsay 很遗憾没有,因为我有几个弹出窗口,每个窗口都包含不同的控件和功能。
标签: xaml popup uwp win-universal-app