Advertisement
elGuille

Código XAML de ejemplo de usar un control en dos sitios

Feb 4th, 2013
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 4.95 KB | None | 0 0
  1. <Page
  2.    x:Class="Prueba_AppStore.MainPage"
  3.    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4.    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5.    xmlns:local="using:Prueba_AppStore"
  6.    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  7.    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  8.    mc:Ignorable="d">
  9.  
  10.     <Page.Resources>
  11.         <ResourceDictionary>
  12.             <Style x:Key="AlarmasAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
  13.                 <Setter Property="AutomationProperties.AutomationId" Value="AlarmasAppBarButton"/>
  14.                 <Setter Property="AutomationProperties.Name" Value="Alarmas"/>
  15.                 <Setter Property="Content" Value="&#xE07F;"/>
  16.             </Style>
  17.             <!-- Para el color de fondo de la aplicación y de la AppBar y el título de la configuración -->
  18.             <Style x:Key="ClockAppBarBackground" TargetType="AppBar">
  19.                 <Setter Property="Background" Value="#FF004080" />
  20.                 <Setter Property="BorderBrush" Value="#FF004080" />
  21.             </Style>
  22.             <Style x:Key="AboutClockAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
  23.                 <Setter Property="AutomationProperties.AutomationId" Value="AboutClockAppBarButton"/>
  24.                 <Setter Property="AutomationProperties.Name" Value="Acerca de"/>
  25.                 <Setter Property="Content" Value="&#xE121;"/>
  26.             </Style>
  27.             <Style x:Key="SettingsAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
  28.                 <Setter Property="AutomationProperties.AutomationId" Value="SettingsAppBarButton"/>
  29.                 <Setter Property="AutomationProperties.Name" Value="Settings"/>
  30.                 <Setter Property="Content" Value="&#xE115;"/>
  31.             </Style>
  32.         </ResourceDictionary>
  33.     </Page.Resources>
  34.  
  35.     <Page.BottomAppBar>
  36.         <AppBar x:Name="mainBottomAppBar" Style="{StaticResource ClockAppBarBackground}" Padding="10,0,10,0"
  37.                Closed="mainBottomAppBar_Closed" Opened="mainBottomAppBar_Opened">
  38.             <Grid>
  39.                 <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
  40.                     <Button x:Name="buttonAlarmas"  
  41.                            Style="{StaticResource AlarmasAppBarButtonStyle}" Click="buttonAlarmas_Click" />
  42.                 </StackPanel>
  43.                 <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
  44.                     <Button x:Name="buttonClock"
  45.                            Style="{StaticResource AboutClockAppBarButtonStyle}" Click="button_Clock" />
  46.                     <StackPanel x:Name="spAppBarSettings" Margin="0,0,-10,0">
  47.                         <!-- aquí pondremos el botón cuando se abra esta barra de la aplicación -->
  48.                     </StackPanel>
  49.                 </StackPanel>
  50.             </Grid>
  51.         </AppBar>
  52.     </Page.BottomAppBar>
  53.  
  54.     <Grid Background="#FF105090">
  55.         <Grid.RowDefinitions>
  56.             <RowDefinition Height="110"/>
  57.             <RowDefinition Height="*"/>
  58.             <RowDefinition Height="Auto"/>
  59.         </Grid.RowDefinitions>
  60.  
  61.         <!-- Back button and page title -->
  62.         <Grid>
  63.             <Grid.ColumnDefinitions>
  64.                 <ColumnDefinition Width="120"/>
  65.                 <ColumnDefinition Width="*"/>
  66.             </Grid.ColumnDefinitions>
  67.             <Button x:Name="backButton" Visibility="Collapsed" Click="GoBack"
  68.                    IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}"
  69.                    Style="{StaticResource BackButtonStyle}"/>
  70.             <TextBlock x:Name="pageTitle" x:Uid="MainpageTitle" Grid.Column="1"
  71.                       Text="Pruebas para la Tienda de Windows 8" Style="{StaticResource PageHeaderTextStyle}" />
  72.         </Grid>
  73.        
  74.         <StackPanel Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center">
  75.             <TextBlock Text="Esto estará en el centro (más o menos)" FontSize="30" FontWeight="SemiBold"/>
  76.         </StackPanel>
  77.  
  78.         <Grid Grid.Row="2">
  79.             <Grid.ColumnDefinitions>
  80.                 <ColumnDefinition Width="Auto"/>
  81.                 <ColumnDefinition Width="*"/>
  82.                 <ColumnDefinition Width="Auto"/>
  83.             </Grid.ColumnDefinitions>
  84.             <!-- el MinHeight es para que al quitar el botón (por código)
  85.                 no se mueva lo que haya en medio
  86.                 que se iba para abajo al abrir la appBar -->
  87.             <StackPanel x:Name="spRow2" Grid.Column="2" Orientation="Horizontal" MinHeight="90">
  88.                 <!-- poner aquí el botón de configuración, pero por código -->
  89.                 <Button x:Name="buttonSettings"  
  90.                        Style="{StaticResource SettingsAppBarButtonStyle}" Click="button_Settings" />
  91.  
  92.             </StackPanel>
  93.         </Grid>
  94.  
  95.     </Grid>
  96. </Page>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement