WCF/WF - View model in itemcontrol itemsource - Asked By Lavinia Rayan on 28-Jun-12 06:59 AM

Earn up to 10 extra points for answering this tough question.
Hi,
How to assign view model object to itemcontrol itemsource?
Ravichandran K replied to Lavinia Rayan on 07-Sep-12 12:06 AM

<ItemsControlItemsSource="{BindingPath=Items}"HorizontalAlignment="Center"VerticalAlignment="Center"> 
        <
ItemsControl.ItemTemplate> 
          <
DataTemplate> 
            
<local:ChildView> 
           
</local:ChildView> 
          </DataTemplate> 
        </
ItemsControl.ItemTemplate> 
      </
ItemsControl> 


A solution to this may look like this;

<ItemsControl ItemsSource="{Binding Path=Items}" HorizontalAlignment="Center" VerticalAlignment="Center">
        <ItemsControl.ItemTemplate>
          <DataTemplate>
            <Grid>
              <TextBlock Text="{Binding}" Visibility="Collapsed" x:Name="HiddenTextBlock"/>
              <local:ChildView>
                <local:BindingBehaviors.ObjectToObjectBinding>
                  <local:ObjectToObjectBinding Source="{Binding Path=Text, ElementName=HiddenTextBlock}" Target="{Binding Path=MyProperty, Mode=TwoWay}"/>
                </local:BindingBehaviors.ObjectToObjectBinding>
              </local:ChildView>
            </Grid>           
          </DataTemplate>
        </ItemsControl.ItemTemplate>
      </ItemsControl>

you can reach out more information from below link....
http://blogs.profitbase.com/tsenn/?p=56

http://stackoverflow.com/questions/1664399/can-i-declaratively-bind-an-itemscontol-itemssource-to-an-observablecollection-i