How to get a TextBlock handler wrapped in ItemTemplate of ListBox RRS feed

  • Question

  • Hi MSFT,

    How to get a TextBlock handler wrapped in ItemTemplate of ListBox?

    Because I want to modify the property of the element wrapped in ItemTemplate of ListBox.

    <DataTemplate x:Key="ende_listboxTemplate"  >
                <Grid x:Name="ende_item_grid">
                    <TextBlock x:Name="text_block" Text="{Binding}" Margin="0,0,0,0" TextAlignment="Center" TextWrapping="Wrap" Tapped="ende_encrypted_item_tapped" RightTapped="ende_encrypted_item_right_tapped"></TextBlock>
                    <ProgressRing   x:Name="ende_progress_ring"  Margin="0,0,0,0"  IsActive="True"></ProgressRing>
    <ListBox  x:Name="ende_ff_ende_listbox"   ItemTemplate="{StaticResource  ende_listboxTemplate}"
            ItemsSource="{Binding  ende_Colletion}"/>

    c++ code:

    Collections::IVectorView<Object^>^ items = ende_ff_ende_listbox->Items->GetView();
    for (int x = 0; x < items->Size; x++)
    		Object^ item = items->GetAt(x);
    		ListBoxItem^ element = dynamic_cast<ListBoxItem^> (item);
    		String ^ name = element->Name;

    I try to convert item to ListBoxItem, but I failed.

    Please help on that.



    Thursday, March 15, 2012 11:04 AM

All replies

  • Hi Kevin,

    What are you trying to change here? Can you please explain your scenario so we can give you an appropriate answer?


    Friday, March 16, 2012 11:10 PM
  • Hi Rob,

    Thanks a lot for your reply at first.

    I use DataTemplate to add items dynamically.

           just like this:  ende_Colletion->Append("test1");ende_Colletion->Append("test2");

    And want to dynamically change item's proprety.

          just like this: ende_progress_ring->IsActive = false.

         because ende_progress_ring is wrapped in the DataTemplate.

         So my question is how to change the property of ende_progress_ring wrapped in DataTemplate?



    Monday, March 19, 2012 1:10 AM