Link to home
Start Free TrialLog in
Avatar of -Tikigod-
-Tikigod-Flag for United States of America

asked on

Controls named inside an item template can't be referenced in the code-behind file.

Hi there,
I'm having an issue where in XAML I define a ListBox with a ListBox.ItemTemplate property element. I put an Image control in the template with a name "envelopeImage" but IntelliSense won't show it to me in the code-behind file (in C#). Is there another way to access the Image? I need to set the source to an embedded resource (namely an image of an envelope). Thanks!
<ListBox HorizontalContentAlignment="Stretch" ItemsSource="{Binding Path=myItems}" Margin="10" Name="newItemsListBox">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Border BorderBrush="Blue" BorderThickness="3">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="2*" />
                                        <RowDefinition Height="6*" />
                                        <RowDefinition Height="2*" />
                                    </Grid.RowDefinitions>
                                    <StackPanel Grid.Row="0" Orientation="Horizontal">
                                        <Image Name="envelope" />
                                        <!--...-->
                                    </StackPanel>
                                    <!--...-->
                                </Grid>
                            </Border>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Avodah
Avodah
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial