As can be adjusted in a WPF application developed to change the resolution?
I read about WPF and I have following concerns: Normally when we develop applications (in my case) try to work with percentages that automatically adjusts to changes in resolution.
Currently I am developing an application to wpf apreder together to manage its operation on a 1280 * 1024 and when I wanted to see would be a resolution of 1024 * 768 application does not comply with the new resolution.
This is an example of code 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>
I am doing wrong things? There is a better practice?
Thank you very much
Good afternoon,
After reading and analyzing code tutorials I came across a way to solve my problem using the With its help you can get the contents of a window is adjusted according to the size or the same as in my case the resolution.
Never mind that it defines a fixed size of the objects (such as myself) the action seeks to bring up the window size.
The solution would be code:
<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>
If someone else gets a different solution or cleaner, go ahead write it
链接地址: http://www.djcxy.com/p/36836.html上一篇: 是否有任何标准的屏幕分辨率在c#中开发winform应用程序?
下一篇: 可以在WPF应用程序中调整以改变分辨率?