Snapchat-like app

本文关键字:app Snapchat-like | 更新日期: 2023-09-27 17:53:13

我想有一个"类似snapchat "的UWP应用程序。

下面是一小段代码:

 <Grid>
            <CaptureElement Stretch="Uniform"/>
            <Button 
                    x:Name="button1" 
                    Content="Button" 
                    Height="126"  Width="162" 
                    Click="button1_Click" 
                    FontSize="72"
                    Margin="185,543,0,51"/>
</Grid>

然而,因为我希望我的应用程序能够被用于手机和桌面,我希望能够调整窗口的大小,让它自动调整(使用VisualStateManager)

我尝试使用行来完成:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <CaptureElement Stretch="Uniform" Grid.Row="0"/>
    <Button 
            x:Name="button1" 
            Content="Button" 
            Height="126"  Width="162" 
            Click="button1_Click" 
            FontSize="12"
            Grid.Row="1"/>
</Grid>

这似乎是好的,但图片不是全屏-你可以清楚地从CapturePreview按钮分开,但想法是有全屏预览只有按钮图标。

有办法完成我的想法吗?

Snapchat-like app

可以设置网格。RowSpanProperty属性。

既然你把你的Grid分成两部分:

<Grid.RowDefinitions>
     <RowDefinition Height="*"/>
     <RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

如果你想让你的CaptureElement延伸到整个Grid,你可以在这里设置Grid.RowSpan="2":

<CaptureElement Stretch="Uniform" Grid.Row="0" Grid.RowSpan="2"/>

顺便说一下,如果你有关于相机的其他问题,你可以参考官方的基本相机应用程序示例。