我正在使用c#/ xaml为Windows商店开发一个应用程序。
的Xaml:
<Popup x:Name="EditQuantityPopup"
x:Uid="EditQuantityPopup"
AutomationProperties.AutomationId="EditQuantityPopup"
IsLightDismissEnabled="True"
IsOpen="{Binding IsEditPopupOpened, Mode=TwoWay}">
<Grid x:Name="PopupPanel"
Background="{StaticResource ApplicationPageBackgroundThemeBrush}"
Opacity=".9"
Height="100"
Width="230">
<Grid x:Name="ContentPopupGrid"
Grid.Row="1"
Margin="20,0,10,15">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="Auto" />
<!--<ColumnDefinition />-->
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
Text="{Binding Text}"
VerticalAlignment="Center"
TextTrimming="WordEllipsis"
FontSize="15"
Foreground="White"></TextBlock>
<ProgressRing Grid.Column="2" IsActive="{Binding LoadingData}" Height="75" Width="75"></ProgressRing>
</Grid>
</Grid>
</Popup>
将弹出窗口放在底部应用栏顶部的代码:
private void EditQuantityPopup_Opened(object sender, object e)
{
int margin = 10;
int appbarHeight = 90;
EditQuantityPopup.HorizontalOffset = margin;
EditQuantityPopup.VerticalOffset = Window.Current.CoreWindow.Bounds.Bottom - appbarHeight - PopupPanel.Height - margin;
}
如何更改弹出窗口应放在窗口右上角的代码?
答案 0 :(得分:0)
这取决于容纳PopUp元素的布局类型。试试这个
EditQuantityPopup.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Right;
EditQuantityPopup.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top;
根据您的设置,除了上述内容之外,您可能需要将PopUp元素移动到网格中的新列。例如
Grid.SetColumn(EditQuantityPopup, [your column number]);
如果它在Canvas中你可以使用
var left = Window.Current.Bounds.Width - EditQuantityPopup.ActualWidth;
Canvas.SetLeft(EditQuantityPopup, left);
Canvas.SetTop(EditQuantityPopup, 0);
希望有所帮助