可以在WPF应用程序中调整以改变分辨率?

我读了WPF,我有以下担忧:通常,当我们开发应用程序时(在我的情况下)尝试使用可自动调整以解决分辨率变化的百分比。

目前我正在开发一个应用程序到wpf apreder一起来管理其在1280 * 1024上的操作,当我想看到的将是1024 * 768分辨率的应用程序不符合新的分辨率。

这是代码AXML的一个例子。

<Window x:Class="pedido"        
    WindowState="Maximized"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="pedido" 
WindowStyle="None" Name="VentanaPeido" Background="White" BorderThickness="2" AllowsTransparency="False">
<Window.Resources>      
    <Style x:Key="myHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
        <Setter Property="Visibility" Value="Collapsed" />
    </Style>
</Window.Resources>

<StackPanel Name="todo" HorizontalAlignment="Center" Width="1280" Height="1024">
    <Grid Background="Maroon" Name="grdInicio">
        <StackPanel Name="titulo" Width="1280" Height="214">
            <StackPanel Height="10">
            </StackPanel>
            <StackPanel Name="tituloLogo" Orientation="Horizontal" HorizontalAlignment="Center">
                <StackPanel  Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center" Width="245" Height="150">
                    <Image  Name="logoAuto" Width="150" Height="148" Stretch="Uniform" HorizontalAlignment="Right" />

                </StackPanel>
                <StackPanel  HorizontalAlignment="Center" Width="765" Name="tituloLetras">
                    <Label  Height="67.5"  FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="1" Name="Mensaje" FontSize="44" Foreground="White" Width="707.5" OpacityMask="Black">Mensaje</Label>
                    <Label HorizontalAlignment="Center"  Canvas.Top="180" FontSize="48" FontWeight="Bold" Foreground="Gold" Height="85" Name="NombreTienda" Width="565" OpacityMask="Black">Nombre Tienda</Label>

                </StackPanel>

            </StackPanel>
            <StackPanel.Background>
                <ImageBrush  x:Name="fondoTitulo" Stretch="Uniform">
                </ImageBrush>
            </StackPanel.Background>
        </StackPanel>
    </Grid>

        <StackPanel Name="espacio1" Background="White" Height="12" Width="1280" VerticalAlignment="Top"></StackPanel>
        <StackPanel Name="panel" Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Left" Width="1280" Height="800">
            <StackPanel Name="ticket" Orientation="Vertical" HorizontalAlignment="Center" Width="635" Height="1280">
                <ListView HorizontalAlignment="center" VerticalAlignment="Top"  Name="lvPedido"  Height="600" ItemsSource="{Binding}" FontSize="30" IsEnabled="True" IsTextSearchEnabled="False" IsTabStop="False" Grid.IsSharedSizeScope="False" BorderBrush="Black" ItemStringFormat="center" Background="White" FontFamily="Arila" BorderThickness="5" Opacity="3" FontWeight="Bold">
                    <ListView.View>
                        <!--ColumnHeaderContainerStyle="{StaticResource myHeaderStyle}"-->
                        <GridView ScrollViewer.IsDeferredScrollingEnabled="False"  >

                        <GridViewColumn Width="60">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock TextAlignment="Left" HorizontalAlignment="Left" Text="{Binding Path=cantidad}"/>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Width="316">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock TextAlignment="Left" Text="{Binding Path=item}"/>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                         </GridViewColumn>
                        <GridViewColumn Width="80">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock TextAlignment="center" HorizontalAlignment="Center"  Text="{Binding Path=moneda}"/>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>

                        <GridViewColumn Width="150" >
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock TextAlignment="Right" HorizontalAlignment="Right" Text="{Binding Path=monto}"/>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>

                        </GridView>
                    </ListView.View>
                </ListView>
                <StackPanel   HorizontalAlignment="Center" Height="20"></StackPanel>

                <StackPanel Margin="15"  HorizontalAlignment="Right" Width="555" Height="150">
                    <TextBlock  HorizontalAlignment="Center" FontSize="40" Foreground="Black" Height="50" Width="535" FontWeight="Bold" Text="Total"></TextBlock>
                    <TextBlock Name="Monto" HorizontalAlignment="Center" FontWeight="Bold" FontSize="80" Width="565" Height="100" Opacity="2" OpacityMask="Magenta" OverridesDefaultStyle="True" Foreground="White">monto</TextBlock >
                </StackPanel>

                <StackPanel.Background>
                    <ImageBrush  x:Name="fondo1">
                    </ImageBrush>
                </StackPanel.Background>
            </StackPanel>
        <StackPanel Width="10" Height="800" Background="White"></StackPanel>
            <StackPanel Name="imagenProducto" VerticalAlignment="Top" Orientation="Vertical" HorizontalAlignment="Center" Width="635" Height="800">

            <StackPanel Name="Imagen1">
                <Image Name="itemP" Width="635" Height="299" Stretch="Uniform" Margin="2"/>
            </StackPanel>
            <StackPanel Name="Espacio" Background="White" Width="635" Height="10"></StackPanel>

              <StackPanel Name="Video" Width="635" Height="299" VerticalAlignment="Top">
                <MediaElement Name="Promo" Stretch="Uniform" Width="635" Height="299" LoadedBehavior="Manual" UnloadedBehavior="Stop" MediaEnded="Promo_MediaEnded"/>
                <StackPanel.Background>
                    <ImageBrush  x:Name="videoPromo" Stretch="Uniform">
                    </ImageBrush>
                </StackPanel.Background>
            </StackPanel>
            <StackPanel Name="Imagen2" Visibility="Collapsed" Width="635" Height="299">
                <Image Name="itemS" Width="635" Height="299" Stretch="Uniform" Margin="2" Tag="true" />
           </StackPanel>
           <StackPanel.Background>
                <ImageBrush  x:Name="fondo2">
                </ImageBrush>
            </StackPanel.Background>
        </StackPanel>


        </StackPanel>

</StackPanel>

我做错了什么? 有一个更好的做法?

非常感谢你


下午好,

阅读和分析代码教程后,我遇到了一种方法来解决我的问题,使用它的帮助,你可以得到一个窗口的内容根据大小调整或像我的情况一样调整分辨率。

不要紧,它定义了一个固定大小的对象(比如我自己),这个动作试图调出窗口大小。

解决方案将是代码:

<Window x:Class="pedido"        
    WindowState="Maximized"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="pedido" 
WindowStyle="None" Name="VentanaPeido" Background="White" BorderThickness="2" AllowsTransparency="False">
<Window.Resources>      
    <Style x:Key="myHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
        <Setter Property="Visibility" Value="Collapsed" />
    </Style>
</Window.Resources>

<StackPanel Name="todo" HorizontalAlignment="Center" Width="1280" Height="1024">
 <Viewbox>
      <......>
   </Viewbox>

</StackPanel>

如果其他人获得不同的解决方案或更清洁,请继续写下来

链接地址: http://www.djcxy.com/p/36835.html

上一篇: As can be adjusted in a WPF application developed to change the resolution?

下一篇: Interview questions: WPF Developer