2009-03-12 7 views
0

Je lis à propos de WPF et j'ai des préoccupations suivantes: Normalement, lorsque nous développons des applications (dans mon cas), essayez de travailler avec des pourcentages qui s'ajustent automatiquement aux changements de résolution.Comme peut être ajusté dans une application WPF développée pour changer la résolution?

Actuellement, je développe une application WPF apreder ensemble pour gérer son fonctionnement sur une résolution de 1280 * 1024 et quand je voulais voir serait une résolution de 1024 * 768 application ne se conforme pas à la nouvelle résolution.

Ceci est un exemple de 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> 

que je fais des choses mauvaises? Il y a une meilleure pratique?

Merci beaucoup

+0

Je ne comprends pas la question. – Micah

Répondre

0

Bonjour,

Après lecture et l'analyse des didacticiels de code, je suis tombé sur un moyen de résoudre mon problème en utilisant la Avec son aide, vous pouvez obtenir le contenu d'une fenêtre est ajustée en fonction à la taille ou le même que dans mon cas la résolution.

Peu importe qu'il définisse une taille fixe des objets (comme moi-même) l'action cherche à faire monter la taille de la fenêtre.

La solution serait 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> 

Si quelqu'un d'autre obtient une autre solution ou plus propre, allez-y l'écrire

+0

Le VentanaPeido pue en portugais. :-) –

Questions connexes