Hello Everyone,
I am a new user to Windows Presentation Framework.
I tried working with some samples with the help of WPF Book by Oreilly.
I got struck here:
<
ListBox ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="True"><
ListBox.ItemTemplate><
DataTemplate><TextBox>
<TextBlock Text="{Binding Path=Name}" />:
<
TextBlock Text="{Binding Path=Nick}" /></TextBox>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Here i could not find the "DataTemplate" Tag at all.
Plz anyone help.
Thanks in Advance,
Dhivya.

Could not find <DataTemplate> Tag inside <ListBox.ItemTemplate>.
Denis B
I referred to Oreilly Book( September 2005 : First Edition).
Now i am using Jan CTP of WPF.
Where Could i find the latest Updates
Thanks,
Dhivya.
JEstes
By "not found" you mean it doesn't show up in intellisense in the XML editor, right You can't count on the intellisense right now because the schema for XAML isn't complete. Any warnings or errors from the XML editor should be taken with a grain of salt right now. The only way to know for sure if something works or not is to compile it and check the compile time errors.
HTH,
Drew
Firerx
This has not changed. If you check out the SDK you will see ListBox still has an ItemTemplate property and it is still of type DataTemplate.
So when you say:
What exactly do you mean by that
Cheers,
Drew
C# d0t NeT
Yes, it does not show up the <DataTemplate> in intellisense.
I get this Error while Compilation:
A Template can only have a single root element. 'TextBlock' is not allowed. Line 16 Position 12.
And when i keep the Mouse Over <DataTemplate> Tag, I could see this:
The element 'ListBox.ItemTemplate' in namespace 'http://schemas.microsoft.com/winfx/avalon/2005' has invalid child element 'DataTemplate' in namespace 'http://schemas.microsoft.com/winfx/avalon/2005'. List of possible elements expected: 'sgMarkupExtension, sgResourceKey, ComponentResourceKey, sgTemplateKey, DataTemplateKey, Binding, sgMultiBindingBase, MultiBinding, PriorityBinding, DynamicResource, StaticResource, TemplateBinding, ThemeDictionary, sgDataTemplate, HierarchicalDataTemplate in namespace 'http://schemas.microsoft.com/winfx/avalon/2005'.
Thanks,
Dhivya N.
scudrock
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Name}"/>
<TextBlock Text="{Binding Path=Nick}"/>
</StackPanel>
</DataTemplate>
Regarding the book, you wil find here the updated samples
http://www.sellsbrothers.com/writing/avbook/
Aaron.W
<ListBox BorderBrush="Black" ItemsSource="{Binding Source={StaticResource colors}}" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate>
<DataTemplate>
<Rectangle Width="15" Height="15" Fill="{Binding}"/>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
that code for me doesn't work for me in 1 project but works in another project. This is a similar problem i think to what was originally posted The part if complains about for me is: DataTemplate is an invalid child for <ListBox.ItemTemplate>. Is there something i need to add to the project file or is my SDK version that is just buggy. I have 2006.09 version. I have this code in a resource dictionary and it being accessed by a XAML UI control.
Owen3
Hi Drew,
This is my XAML File:
<
Window x:Class="DataBindingAppln.Window1" xmlns="http://schemas.microsoft.com/winfx/avalon/2005" xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005" Title="NickNames"><
DockPanel x:Name="dockPanel"><
StackPanel DockPanel.Dock="Top" Orientation="Horizontal"><
TextBlock VerticalAlignment="Center">Name: </TextBlock><
TextBox Text="{Binding Path=Name}" /><
TextBlock VerticalAlignment="Center">Nick: </TextBlock><
TextBox Text="{Binding Path=Nick}" /></StackPanel>
<Button DockPanel.Dock="Bottom" x:Name="addButton">Add</Button>
<ListBox ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="True">
<ListBox.ItemTemplate>
<DataTemplate> is not found. I could see <DataTemplateKey> alone.
Inside DataTemplateKey, i coud not find the TextBlock Tag.
<TextBlock Text="{Binding Path=Name}" />:
<
TextBlock Text="{Binding Path=Nick}" /></
DataTemplate></
ListBox.ItemTemplate></
ListBox></
DockPanel></
Window>Plz Help.
Thanks,
Dhivya.