Home > Windows 8, XAML > ListBox e Items orizzontali

ListBox e Items orizzontali

Oggi mi ritrovavo a programmare la mia bellissima (eh si, sono modesto) KeepSecret per Win8 e ho avuto un lampo di genio: facciamo una ListBox e posizioniamo gli Item in orizzontale… Ho trovato subito difficoltà… E’ da pochissimo che programmo per Windows 8, e l’allineamento orizzontale non l’avevo mai provato, neppure in Windows Phone!

Dopo aver cercato un po’ in giro mi sono arreso e ho provato a fare qualcosa da me e sono felice di dire che ho raggiunto l’obiettivo con questo pezzo di codice XAML:

<Grid x:Name="LayoutRoot">
     <ListBox HorizontalAlignment="Left" Margin="0,0,0,0" Name="listbox1" VerticalAlignment="Top">
          <ListBox.ItemsPanel>
               <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" />
               </ItemsPanelTemplate>
          </ListBox.ItemsPanel>
          <ListBox.ItemContainerStyle>
               <Style TargetType="ListBoxItem">
                    <Setter Property="Padding" Value="30,0,0,0" />
                    <Setter Property="Background" Value="#FF00FF00" />
               </Style>
          </ListBox.ItemContainerStyle>
          <Button>Primo bottone</Button>
          <Button>Secondo bottone</Button>
          <Button>Terzo bottone</Button>
     </ListBox>
</Grid>

Provare per credere 😉

Categorie:Windows 8, XAML
  1. aprile 10, 2013 alle 3:57 am

    I want to to thank you for this excellent read!
    ! I absolutely loved every bit of it. I’ve got you book marked to check out new things you post…

  2. giugno 14, 2013 alle 8:16 PM

    Hello superb blog! Does running a blog such as this require a large amount of work?
    I’ve very little expertise in programming but I had been hoping to start my own blog soon. Anyways, should you have any ideas or tips for new blog owners please share. I know this is off topic however I just had to ask. Thank you!

  3. luglio 28, 2013 alle 5:03 PM

    The decor on the inside of the restaurant is absolutely beautiful.
    Below are listed a few popular pubs where one
    can chill in Mumbai. They feature almost nightly drink specials and some form of entertainment
    every night of the week–DJ’s, live music, trivia, you name it.

  4. settembre 19, 2013 alle 2:28 PM

    Nowadays, you can get the ultimate wedding luxury for
    an incredibly affordable price that will fit into your
    wedding budget. If a family has chosen to cremate the remains there are options available.
    Well Amanda-Lina Sposa Boutique is hosting a Casablanca Bridal Trunk show from Dec 8 ‘ 18.

  5. gennaio 9, 2016 alle 11:21 am

    Hurrah! Finally I got a weblog from where I be able to really get helpful facts concerning my study and
    knowledge.

  1. No trackbacks yet.

Lascia un commento