I’ve started to learn about GridView (XAML) for Windows 8 Store apps. I’ve used the ItemsPage example to try and have a look at the code.
My aim is use it as a horizontal menu, on the click event it will simply open another xaml page.
I’ve edited the SampleDataSource.cs file and filled up with the wanted content, i thought that there would be an easier, cleaner way of doing this. This Menu won’t be dynamic and won’t change so i’m looking for a way to statically add the menu items.
I can do the following to add a simple text entry;
<x:String>Item 1</x:String>
But i have i’m not sure how to bind to certain parts, such as the image and title elements
Right, i think i’m understanding this a little bit more. The following code would try and bind to itemsViewSource
<CollectionViewSource
x:Name="itemsViewSource"
Source="{Binding Items}"
d:Source="{Binding AllGroups, Source={d:DesignInstance Type=data:SampleDataSource, IsDesignTimeCreatable=True}}"/>
So would i need to create a new list, such as;
List<String> itemsList = new List<string>();
itemsList.Add("Item 1");
itemsList.Add("Item 2");
Only issue is that each item (line) would need a Title and Image text field and how to bind those to the correct items.
If your
ItemsControl(GridView) needs to display more than one bound item for each list item – you need to bind its Source to a list of something more than a string unless you want to parse the strings. In your case you would have something likeThen in your
ItemTemplate/DataTemplateyou would have twoTextBlocks – that bind to the properties of your item view model like this:Text="{Binding Title}",Text="{Binding ImageText}".Of course you need to define your
TitleAndImageText, e.g.