locked
Binding a text from a Class

    Question

  • Hi Guys Need Your Help please,

    I want to make a Binding Text from a class to a TextBlock.

    When i click on a ListItem will Appear this TextBlock Like next image but the Text cannot Appear what should i do ?

    Tuesday, April 01, 2014 12:59 PM

Answers

  • You'll have to add a DataTemplate to your xaml in your page's resources section:

    <DataTemplate x:Key="mytemplate">

    <TextBlock Text="{Binding Name}" Width="{Binding Width}" Height="{Binding Height}" />

    </DataTemplate>

    And then for your listbox, grid or whatever control you're binding to the ListItem collection, add

    ItemTemplate="{StaticResource mytemplate}"

     

    Darin R.

    Tuesday, April 01, 2014 4:51 PM