locked
GridView Image Databinding

    Question

  • Hi I want to display 16 different images binded to CS class, and eachtime press button it has to change. I tried to do it by 2 images but have no result.

    <

    VariableSizedWrapGridx:Name="WrapGrid1"

    ItemHeight="120"


                         

    ItemWidth="120"


                            

    Orientation="Horizontal"Grid.Row="2"Grid.Column="1"Margin="0,0,5,0">


               

    <ImageSource="{BindingImage1}" />


               

    <ImageSource="{BindingImage2}" />


           

    </VariableSizedWrapGrid>

    public

    ObservableCollection<GridViewSource> MyGrid = newObservableCollection<GridViewSource>();

           

    publicStartPage()

            {

               

    this.InitializeComponent();

                MyGrid.Add(

    newGridViewSource("Assets/Logo.scale-100.png","Assets/Logo.scale-100.png"));

                MyGrid.Add(

    newGridViewSource("Assets/SmallLogo.scale-100.png","Assets/SmallLogo.scale-100.png"));

               

                WrapGrid1.DataContext = MyGrid;

            }

    public

    classGridViewSource


            {

               

    publicGridViewSource() { }

               

    publicGridViewSource(stringImage1,stringImage2)

                {

                    Imagepath1 = Image1;

                    Imagepath2 = Image2;

                }

               

    publicstringImagepath1 { get; set; }

               

    publicstringImagepath2 { get; set; }

               

    publicoverridestringToString()

    {

    returnImagepath1+Imagepath2;

    }

             

            }

    Wednesday, September 10, 2014 2:48 AM

All replies

  • I don't see a button in this code... what exactly are you trying to do?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, September 11, 2014 7:55 PM
    Moderator