locked
XAML control that supports data binding except listview or listbox.

    Question

  • Is there any XAML control that supports data binding except listview or listbox. I am developing an application using windows azure mobile services table. After retrieving the data from table I am binding the list to a listview as a small preview. When user will select any Item from the list view I want to display the details of the selected item. Which XAML control will be suitable for this task. I can use lots of TextBoxes  and assign its Text property from C# code. I dont think It is a good practice. Thank you
    Monday, November 03, 2014 4:33 AM

Answers

  • All of them. Data-binding is quite central to how Xaml works.

    It's not clear to me exactly what you're looking for here. Are you trying to show the item details within your list control? Or do you want to select a single item from the list control and then show more details about that elsewhere?

    The first you'd do by templating the list. The second with a master/detail pattern binding.

    See:

    The Using  the right interaction pattern in the Guidelines for List view and grid view controls

    Quickstart: Adding ListView and GridView controls

    How to create a master-details binding

    Monday, November 03, 2014 6:04 AM
    Moderator
  • If you want to display collection of data use ListView, GridView, ListBox, or ItemsControl. If you want to display the selected item, you can put TextBlock in a Grid, set the DataContext of the Grid to the selected item of the ListBox and DataBind the TextBlock. Your XAML will look like the text below.

    <ListBox x:Name="myList" ItemsSource="{Binding MyAzureCollection}"/>

    <Grid DataContex="{Binding ElementName=myList, Path=SelectedItem}">

    <TextBlock Text="{Binding PropertyName}"/>

    </Grid>

    Hassan

    Monday, November 03, 2014 6:09 AM

All replies

  • All of them. Data-binding is quite central to how Xaml works.

    It's not clear to me exactly what you're looking for here. Are you trying to show the item details within your list control? Or do you want to select a single item from the list control and then show more details about that elsewhere?

    The first you'd do by templating the list. The second with a master/detail pattern binding.

    See:

    The Using  the right interaction pattern in the Guidelines for List view and grid view controls

    Quickstart: Adding ListView and GridView controls

    How to create a master-details binding

    Monday, November 03, 2014 6:04 AM
    Moderator
  • If you want to display collection of data use ListView, GridView, ListBox, or ItemsControl. If you want to display the selected item, you can put TextBlock in a Grid, set the DataContext of the Grid to the selected item of the ListBox and DataBind the TextBlock. Your XAML will look like the text below.

    <ListBox x:Name="myList" ItemsSource="{Binding MyAzureCollection}"/>

    <Grid DataContex="{Binding ElementName=myList, Path=SelectedItem}">

    <TextBlock Text="{Binding PropertyName}"/>

    </Grid>

    Hassan

    Monday, November 03, 2014 6:09 AM
  • I think you may refer to this video from YouTube .

    Windows Store App - DataBinding ListBox

    or 

    you may refer to this website

    http://www.c-sharpcorner.com/UploadFile/65fc13/binding-data-items-to-a-data-control-in-windows-8-metro-appl/


    Monday, November 03, 2014 6:53 AM