Hi
Here is a problem that one of my colleagues who is just starting to use WPF got himself into. He was working on an application that displays items using an ItemsControl and uses a DataTemplate. Inside the DataTemplate he used an Image. Here is the Xaml code:
1: <Window.Resources>
2: <Image Source="Creek.jpg" x:Key="IMG"></Image>
3: </Window.Resources>
4: <Grid>
5: <ItemsControl ItemsSource="{Binding}">
6: <ItemsControl.ItemTemplate>
7: <DataTemplate>
8: <Border BorderThickness="2" BorderBrush="Black"
9: CornerRadius="3" MinHeight="10">
10: <ContentControl Content="{StaticResource IMG}"/>
11: </Border>
12: </DataTemplate>
13: </ItemsControl.ItemTemplate>
14: </ItemsControl>
15: </Grid>
This is a much simpler example, but the principal is the same.
Can you see what was he doing wrong?
We pay for user submitted tutorials and articles that we publish. Anyone can send in a contribution
Learn More