How to access a control placed inside data template of listbox?

Posted by Subhen on Stack Overflow See other posts from Stack Overflow or by Subhen
Published on 2010-04-09T05:10:07Z Indexed on 2010/04/09 5:13 UTC
Read the original article Hit count: 318

Hi I have the following code:

<ListBox x:Name="foldersListBox" Grid.Column="0" MouseLeftButtonUp="foldersListBox_MouseLeftButtonUp" 


                             BorderThickness="0"  Height="AUTO" 
                             ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                             ScrollViewer.VerticalScrollBarVisibility="Disabled">
                        <DataTemplate>
                            <Border BorderBrush="LightGray"
                            BorderThickness="2"
                            CornerRadius="4">
                                <Image x:Name="folderImage" Width="70" Height="70" Margin="3" />
                            </Border>
                        </DataTemplate>
</ListBox>

Now when I am trying to access folderImage from code behind. I can use the loaded event and typecast the sender as Image type , but I dont want that way.

Help plz.

Thanks, Subhen

© Stack Overflow or respective owner

Related posts about silverlight-3.0

Related posts about Silverlight