C sharp - Data binding XAML y C#

 
Vista:
sin imagen de perfil

Data binding XAML y C#

Publicado por Carlos (6 intervenciones) el 07/03/2017 20:03:15
Hola, mi problema es el siguiente: estoy intentando hacer data binding en xaml de una lista de imagenes, el problema es que no se me muestra nada, pero si en vez de imagenes hago el data binding con texto si se muestra el contenido, no se cual es el problema, cualquier respuesta sera de gran ayuda.

Codigo XAML

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<Page
    x:Class="PruebaExamen.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:PruebaExamen"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
 
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <ListView HorizontalAlignment="Left" Height="217" Margin="507,72,0,0" VerticalAlignment="Top" Width="360" ItemsSource="{Binding ListImagen}"/>
 
    </Grid>
</Page>

Codigo ModeloVista.cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Collections.ObjectModel;
 
 
namespace PruebaExamen.Clases
{
    class ModeloVista : INotifyPropertyChanged
    {
        private ObservableCollection<Imagen> imagenes;
        private List<string> pr;
        public ModeloVista()
        {
            imagenes = new ObservableCollection<Imagen>();
            pr = new List<string>();
            //imagenes2 = new List<Uri>();
        }
 
        public List<string> EstoPrueba
        {
            get { return pr; }
            set { pr = value; NotifyPropertyChanged("Esto es una prueba"); }
        }
 
        public ObservableCollection<Imagen> ListImagen
        {
            get
            {
                return imagenes;
            }
        }
 
        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(string propName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
            }
        }
    }
}


Codigo imagen.cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
 
namespace PruebaExamen.Clases
{
    class Imagen{
 
        private Uri Limagen;
        private string prueba;
        public Uri LImagenes
        {
            get { return Limagen; }
            set { Limagen = value; NotifyPropertyChanged("Limagen"); }
        }
 
        public string prueb
        {
            get { return prueba; }
            set { prueba = value; NotifyPropertyChanged("prueba"); }
        }
 
        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(string propName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
            }
        }
 
    }
}

Gracias de antemano.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder