image47dd1de4

Buenas,

me lo voy a apuntar ahora que me lo han mostrado 10 veces, porque si no me mareo. El tema es el siguiente, cuando te peleas con WPF, Silverlight, o alguna otra tecnología que haga un uso excesivo de formatos con etiquetas, pues el tema de la edición en modo texto puede ser bastante complicado. Una gran solución “visual” para estos casos es aprovechar el formateo que nos ofrece Visual Studio, donde se separa un atributo por línea. Esta opción se activa desde el menú [Tools // Options], en la sección [Text Editor // XAML // Formatting // Spacing] seleccionado la opción [Position each attribute on separate line]

image

Por ejemplo, volviendo al ejemplo que publiqué hace 2 días podemos ver parte del XAML con este formato

   1: <TextBlock Text="Merry Christmas" Grid.Row="0" Grid.Column="1" FontSize="24" Foreground="White" 

   2: FontFamily="Segoe UI Semilight" FontWeight="Bold" Margin="0" HorizontalAlignment="Center" />

   3: <Canvas x:Name="canvasContent" Margin="10,10,0,0" Grid.Row="0" Grid.Column="0" Grid.RowSpan="2">

   4: <Grid Grid.Column="1" Grid.Row="1"><Border BorderThickness="3" BorderBrush="White" CornerRadius="10" 

   5: Padding="2" HorizontalAlignment="Center" VerticalAlignment="Center"> <Grid>

   6: <Border x:Name="mask" Background="White" CornerRadius="7" /> <StackPanel><StackPanel.OpacityMask>

   7: <VisualBrush Visual="{Binding ElementName=mask}" /></StackPanel.OpacityMask><Image x:Name="CameraViewer" 

   8: Stretch="UniformToFill" MaxWidth="640" MaxHeight="480" /></StackPanel></Grid></Border></Grid>

 

O después de un Ctrl+k, Ctrl+d, lo vemos de una forma más “natural”

   1: <TextBlock Text="Merry Christmas"

   2:            Grid.Row="0"

   3:            Grid.Column="1"

   4:            FontSize="24"

   5:            Foreground="White"

   6:            FontFamily="Segoe UI Semilight"

   7:            FontWeight="Bold"

   8:            Margin="0"

   9:            HorizontalAlignment="Center" />

  10: <Canvas x:Name="canvasContent"

  11:         Margin="10,10,0,0"

  12:         Grid.Row="0"

  13:         Grid.Column="0"

  14:         Grid.RowSpan="2">

  15:     <Grid Grid.Column="1"

  16:           Grid.Row="1">

  17:         <Border BorderThickness="3"

  18:                 BorderBrush="White"

  19:                 CornerRadius="10"

  20:                 Padding="2"

  21:                 HorizontalAlignment="Center"

  22:                 VerticalAlignment="Center">

  23:             <Grid>

  24:                 <Border x:Name="mask"

  25:                         Background="White"

  26:                         CornerRadius="7" />

  27:                 <StackPanel>

  28:                     <StackPanel.OpacityMask>

  29:                         <VisualBrush Visual="{Binding ElementName=mask}" />

  30:                     </StackPanel.OpacityMask>

  31:                     <Image x:Name="CameraViewer"

  32:                            Stretch="UniformToFill"

  33:                            MaxWidth="640"

  34:                            MaxHeight="480" />

  35:                 </StackPanel>

  36:             </Grid>

  37:         </Border>

  38:     </Grid>

  39:     <ContentControl x:Name="contentControlHat1">

  40:         <Image x:Name="imageHat1"

  41:                Width="64"

  42:                Height="64"

  43:                Source="/ElBruno.KinectViewer;component/Images/santa-hat.png"

  44:                Visibility="Hidden" />

  45:     </ContentControl>

 

Ojo, que sobre gustos no hay nada escrito y tal vez esta opción a más de uno no le guste, pues bien … aquí hay una opción para probar y elegir.

 

Saludos @ Home

El Bruno

   

Leave a comment

Discover more from El Bruno

Subscribe now to keep reading and get access to the full archive.

Continue reading