Hello
I'm looking for some guidance and help regarding Pathlistboxes. I currently have an class containing a string object for which i hope to have as a path to an image. My goal is to load a pathlistbox with images depending on the contents of an list of these custom objects.
What i'm not understanding how do i make the pathlistbox.itemsource reference my list of custom objects and display the appropriate image.
I've spent quite a bit of time searching for examples, but if anyone can point me in the right direction, that would be wonderful.
Thanks,
Ethan
** Revised **
Thanks for the help Venkatesh!
So i've tried to write some code building a pathlistbox, below i've added my xaml and cs code
The XAML looks like:
<Page.Resources>
<local:stringImageConverter x:Key="stringImageConverter"/>
<DataTemplate x:Key="DataTemplateItemConverter">
<Image Source="{Binding imageIndex, Converter={StaticResource stringImageConverter}}"></Image>
</DataTemplate>
</Page.Resources>
<ec:PathListBox x:Name="pathListBox" HorizontalAlignment="Right" Margin="0,372,66,71" Width="428">
<ec:PathListBox.LayoutPaths>
<ec:LayoutPath SourceElement="{Binding ElementName=path}"/>
</ec:PathListBox.LayoutPaths>
</ec:PathListBox>
I'm using a converter to take my imageIndex int and add it to a string in this new class i've created
public class stringImageConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return "./Images/env" + value.ToString() + ".jpg";
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
then populate my list with objects as so. The first number after "ball" is my imageIndex for the object.
public List<objObject> Items { get; set; }
public pbox()
{
this.InitializeComponent();
Items = new List<objObject>();
Items.Add(new objObject("Ball", 1,"Basic Game Object","Ball",1,0,0,0,0,0,"Static",1,1,1,1,"env"));
Items.Add(new objObject("Box", 2, "Basic Game Object", "Box", 1, 0, 0, 0, 0, 0, "Static", 1, 1, 1, 1, "env"));
Items.Add(new objObject("Border", 3, "Basic Game Object", "Border", 1, 0, 0, 0, 0, 0, "Static", 1, 1, 1, 1, "env"));
}
Currently all i get is an image on my page showing the path of my pathlistbox! Any further guidance, suggestions or help would be great!
Thanks again,
Ethan