Xaml 将ContentDialog设置为在UWP中显示在页面底部

Xaml 将ContentDialog设置为在UWP中显示在页面底部,xaml,dialog,uwp,windows-phone,Xaml,Dialog,Uwp,Windows Phone,我在RelativeLayout中有几个ContentDialogs,希望它们出现或与“底部”垂直对齐。但似乎无论我尝试什么,对话框总是出现在屏幕的顶部。 这就是他们现在的样子 有什么想法吗? 以下是xaml代码片段: <RelativePanel Height="{Binding ActualHeight, ElementName=Page}" > <ContentDialog x:Name="EntrepriseDialog"

我在RelativeLayout中有几个ContentDialogs,希望它们出现或与“底部”垂直对齐。但似乎无论我尝试什么,对话框总是出现在屏幕的顶部。 这就是他们现在的样子

有什么想法吗? 以下是xaml代码片段:

    <RelativePanel Height="{Binding ActualHeight, ElementName=Page}" >
                <ContentDialog x:Name="EntrepriseDialog"
                        VerticalAlignment="Bottom"
                               Title="Vælg entreprise"
                           PrimaryButtonText=""
                        IsPrimaryButtonEnabled="{Binding IsChecked, ElementName=checkBoxAgree, Mode=OneWay}"
                        MaxWidth="{Binding ActualWidth, ElementName=pageRoot}" Grid.ColumnSpan="2" Margin="30,194,-71,-194">
                    <ListView Name="ListEntreprises" VerticalAlignment="Bottom" SelectionChanged="ListEntreprises_SelectionChanged">
                        <ListView.ItemContainerStyle>
                            <Style TargetType="ListViewItem">
                                <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
                                <Setter Property="Margin" Value="0,0,0,1"></Setter>
                                <Setter Property="Background" Value="Transparent"></Setter>
                                <Setter Property="Padding" Value="5"></Setter>
                            </Style>
                        </ListView.ItemContainerStyle>
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <StackPanel>
                                        <TextBlock>
                            <Run FontSize="15" Text="{Binding Name}"/>
                                        </TextBlock>
                                        <TextBlock Visibility="Collapsed">
                                    <Run Text="{Binding Id}"/>
                                        </TextBlock>
                                    </StackPanel>
                                </StackPanel>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                </ContentDialog>
                <ContentDialog x:Name="SaveChooseDialog"
                        VerticalAlignment="Bottom"
                        Title=""
                           PrimaryButtonText=""

                        IsPrimaryButtonEnabled="{Binding IsChecked, ElementName=checkBoxAgree, Mode=OneWay}"
                        MaxWidth="{Binding ActualWidth, ElementName=pageRoot}" Grid.ColumnSpan="2" Margin="30,148,-71,-148">
                    <ListBox Name="ListBoxSaveMode"  SelectionChanged="ListBoxSaveMode_SelectionChanged">
                        <ListBoxItem>
                            <TextBlock Name="TxtLocally" Text="Gem lokalt"/>
                        </ListBoxItem>
                        <ListBoxItem>
                            <TextBlock Name="TxtServer" Text="Gem på server"/>
                        </ListBoxItem>
                        <ListBoxItem>
                            <TextBlock Name="TxtCancel" Text="Annullér"/>
                        </ListBoxItem>
                    </ListBox>
                </ContentDialog>
                <ContentDialog x:Name="AddPictureDialog"
                        VerticalAlignment="Bottom"
                        Title=""
                           PrimaryButtonText=""

                        IsPrimaryButtonEnabled="{Binding IsChecked, ElementName=checkBoxAgree, Mode=OneWay}"
                        MaxWidth="{Binding ActualWidth, ElementName=pageRoot}" Grid.ColumnSpan="2" Margin="30,142,-71,-142">
                    <ListBox Name="ListBoxAddPicture"  SelectionChanged="ListBoxAddPicture_SelectionChanged">
                        <ListBoxItem>
                            <TextBlock Name="TxtFromCamera" Text="Tag et nyt"/>
                        </ListBoxItem>
                        <ListBoxItem>
                            <TextBlock Name="TxtFromStorage" Text="Vælg fra kamerarulle"/>
                        </ListBoxItem>
                    </ListBox>
                </ContentDialog>
            </RelativePanel>

编辑:整个页面的XAML

<Page
Name="Page"
x:Class="...Pages.Documentation.DocumentationCreatePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:...Pages.Documentation"
xmlns:userControl="using:...Pages.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="#8FBC3E">
<Grid>
    <Grid.Background>
        <ImageBrush Stretch="UniformToFill" ImageSource="/Assets/Images/mainBg.png" />
    </Grid.Background>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <StackPanel>
        <Grid Height="40" Background="#8FBC3E" >
            <StackPanel Orientation="Horizontal">
                <Button Name="BtnBack" Click="BtnBack_Click" Margin="20 0 20 0" >
                    <Button.Template>
                        <ControlTemplate>
                            <TextBlock  FontSize="20" Foreground="White" FontFamily="Segoe MDL2 Assets" Text="&#xE0A6;"></TextBlock>
                        </ControlTemplate>
                    </Button.Template>
                </Button>
                <TextBlock Name="TxtTitle" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White" FontSize="18"/>
            </StackPanel>
        </Grid>
        <userControl:SyncDataControl></userControl:SyncDataControl>
    </StackPanel>
    <Grid Grid.Row="1" Name="StackPanel">
        <ProgressRing Name="SaveProgressRing" IsActive="False" Foreground="#8FBC3E" Width="40" Height="40" Margin="152,239,87,321"  />
        <StackPanel Grid.ColumnSpan="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
            <ListView Name="ListViewDocumentationItems" ScrollViewer.VerticalScrollMode="Disabled" SelectionChanged="ListViewDocumentationItems_SelectionChanged">
                <ListView.ItemContainerStyle>
                    <Style TargetType="ListViewItem">
                        <Setter Property="Height" Value="80"></Setter>
                        <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
                        <Setter Property="VerticalContentAlignment" Value="Center"></Setter>
                        <Setter Property="Margin" Value="0,0,0,1"></Setter>
                        <Setter Property="Background" Value="White"></Setter>
                    </Style>
                </ListView.ItemContainerStyle>
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <Grid VerticalAlignment="Center">
                            <StackPanel Padding="0 0 10 0" Orientation="Horizontal" >
                                <Image Source="{Binding ImageSource}" VerticalAlignment="Center" Height="40" Margin="5 0 5 0"></Image>
                                <TextBlock Foreground="Black" HorizontalAlignment="Left" VerticalAlignment="Center">
                                    <Run FontWeight="Bold" FontSize="20" Text="{Binding Name}"/>
                                </TextBlock>
                            </StackPanel>
                            <Grid HorizontalAlignment="Right">
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Foreground="Black" VerticalAlignment="Center" Padding="0 0 20 0">
                                    <Run FontSize="15" Text="{Binding Count}"/>
                                    </TextBlock>
                                    <Image Width="15" Height="15" VerticalAlignment="Center" Source="/Assets/Images/rightarrow.png" />
                                </StackPanel>
                            </Grid>
                        </Grid>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
            <TextBlock Name="TxtDocDesc" TextWrapping="Wrap" Foreground="Gray" Height="53" />
            <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                <StackPanel Name="PicturePanel" Orientation="Horizontal" Margin="15 0 15 0" />
            </ScrollViewer>
        </StackPanel>
        <Button Name="BtnSave" Grid.Row="2" VerticalAlignment="Bottom" FontSize="25" Click="BtnSave_Click" Background="#8FBC3E" Foreground="White" Height="60" Content="Gem" HorizontalAlignment="Stretch" Margin="5 5 5 5"/>
        <RelativePanel VerticalAlignment="Stretch"  >
            <ContentDialog x:Name="EntrepriseDialog" VerticalContentAlignment="Bottom"
                        RelativePanel.AlignBottomWithPanel="True"
                               Title="Vælg entreprise"
                           PrimaryButtonText=""
                        IsPrimaryButtonEnabled="{Binding IsChecked, ElementName=checkBoxAgree, Mode=OneWay}"
                        MaxWidth="{Binding ActualWidth, ElementName=pageRoot}" >
                <ListView Name="ListEntreprises" VerticalAlignment="Bottom" SelectionChanged="ListEntreprises_SelectionChanged">
                    <ListView.ItemContainerStyle>
                        <Style TargetType="ListViewItem">
                            <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
                            <Setter Property="Margin" Value="0,0,0,1"></Setter>
                            <Setter Property="Background" Value="Transparent"></Setter>
                            <Setter Property="Padding" Value="5"></Setter>
                        </Style>
                    </ListView.ItemContainerStyle>
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <StackPanel>
                                    <TextBlock>
                            <Run FontSize="15" Text="{Binding Name}"/>
                                    </TextBlock>
                                    <TextBlock Visibility="Collapsed">
                                    <Run Text="{Binding Id}"/>
                                    </TextBlock>
                                </StackPanel>
                            </StackPanel>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </ContentDialog>
            <ContentDialog x:Name="SaveChooseDialog"
                        RelativePanel.AlignBottomWithPanel="True"
                        Title=""
                           PrimaryButtonText=""
                        IsPrimaryButtonEnabled="{Binding IsChecked, ElementName=checkBoxAgree, Mode=OneWay}"
                        MaxWidth="{Binding ActualWidth, ElementName=pageRoot}">
                <ListBox Name="ListBoxSaveMode"  SelectionChanged="ListBoxSaveMode_SelectionChanged">
                    <ListBoxItem>
                        <TextBlock Name="TxtLocally" Text="Gem lokalt"/>
                    </ListBoxItem>
                    <ListBoxItem>
                        <TextBlock Name="TxtServer" Text="Gem på server"/>
                    </ListBoxItem>
                    <ListBoxItem>
                        <TextBlock Name="TxtCancel" Text="Annullér"/>
                    </ListBoxItem>
                </ListBox>
            </ContentDialog>
            <ContentDialog x:Name="AddPictureDialog"
                        Title=""
                        PrimaryButtonText=""
                        IsPrimaryButtonEnabled="{Binding IsChecked, ElementName=checkBoxAgree, Mode=OneWay}"
                        MaxWidth="{Binding ActualWidth, ElementName=pageRoot}" >
                <ListBox Name="ListBoxAddPicture" SelectionChanged="ListBoxAddPicture_SelectionChanged">
                    <ListBoxItem>
                        <TextBlock Name="TxtFromCamera" Text="Tag et nyt"/>
                    </ListBoxItem>
                    <ListBoxItem>
                        <TextBlock Name="TxtFromStorage" Text="Vælg fra kamerarulle"/>
                    </ListBoxItem>
                </ListBox>
            </ContentDialog>
            <ContentDialog x:Name="DialogDownloadProgress" 
                   VerticalAlignment="Stretch"
                   Title=""
                   MaxWidth="{Binding ActualWidth, ElementName=pageRoot}">
                <StackPanel Padding="0,50">
                    <TextBlock Name="ProgressTitle" Text="Test test" HorizontalAlignment="Center" Padding="0 0 0 20"/>
                    <ProgressBar x:Name="ProgressBarDownload" HorizontalAlignment="Stretch" IsEnabled="True"></ProgressBar>
                </StackPanel>
            </ContentDialog>
        </RelativePanel>
    </Grid>
</Grid>


看来ContentDialog实例的定位不在开发人员手中,至少在没有自定义版本的情况下是如此。好的,操作系统将为您决定对话框的放置位置

有关更多信息,请参见此处:


因此,如果对话框的位置非常关键,那么您可能必须创建一个自定义控件。

我尝试了您的解决方案,但没有成功。似乎无论我做什么,它总是默认为top。我试图为RelativePanel硬编码一个高度,只是为了确定,但这并没有改变任何东西。Either:/将对话框放入网格并将其网格设置。Row属性设置为较高的值也会得到相同的结果。您能发布整个页面吗?似乎是RelativePanel之外的内容导致了这个问题。我已经编辑了这个问题,整个页面都在底部。:-)谢谢你的努力!至少我现在对我的问题有了答案:-)我现在已经奖励了它。:-)