Answered Create array of picture in XAML?

  • Saturday, August 18, 2012 3:51 PM
     
     

    I want to create an array of picture ,,, how am I supposed to do so using XAML at design time rather than in runtime

    Please help me

All Replies

  • Saturday, August 18, 2012 6:14 PM
     
     

    There are many ways to do what you want.  

    1. How many pictures do you want to show at one time?

    2. What format do you want the display to have?

    3. Do you expect the pictures to show at design time?

    This is a link to a tutorial using a WrapPanel to display a list of images:

    http://www.wpftutorials.com/2011/03/wpf-wrappanel.html

    LS


    Lloyd Sheen

  • Saturday, August 18, 2012 8:14 PM
    Moderator
     
     Answered Has Code

    This is how to create an array of Image in XAML:

    <Window x:Class="WpfApplication61.View.Window3"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="Window3" Height="300" Width="300" >
        <Window.Resources>
            <x:Array Type="Image" x:Key="ImageArray" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib">
                <Image Width="50" Height="50" Source="/WpfApplication61;component/Media/XAMLguy.png"/>
                <Image Width="50" Height="50" Source="/WpfApplication61;component/Media/XAMLguy.png"/>
            </x:Array>
        </Window.Resources>
        <Grid>
            <ItemsControl ItemsSource="{StaticResource ImageArray}"/>
        </Grid>
    </Window>
     

    Your Uri will be different of course. Just so you know what you're seeing here, the application name is "Application61", the file is called "XAMLguy.png" and is in a subfolder called "Media"

      

    You probably know this: The Uri depends on how you include the images in your project, but that as they say is another story ;)

     

    Regards,
    Pete


    #PEJL