Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

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

Avatar of -Tikigod-
-Tikigod-Flag for United States of America asked on
.NET ProgrammingMicrosoft Development
2 Comments1 Solution217 ViewsLast Modified:
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>
ASKER CERTIFIED SOLUTION
Avatar of Avodah
AvodahFlag of Western Sahara imageServes the Most High - Not Religion

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answers