Hi,
I have a listbox that is bound to a textblock as target and also has an xml file as source. My problem now is the correct syntax for inserting another listbox in between the listbox and the xml file.
My code is shown below...
<Window x:Class="newTestApp.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="auto" Width="auto">
<Window.Resources>
<XmlDataProvider x:Key="Recipes" Source="Recipe2.xml" XPath="/recipe/recipeList" /> <!--binds xml and node recipeList to entire window-->
</Window.Resources>
<Grid>
<DockPanel Name="LargeUI" Height="auto" Width="auto" LastChildFill="True"> <!--Main Dock-->
<DockPanel Name="TopDock" DockPanel.Dock="Top" Height="30" Background="LightGray"><!--TopDock--></DockPanel>
<DockPanel Name="BottomDock" DockPanel.Dock="Bottom" Height="100" Background="LightGray" ><!--BottomDock--></DockPanel>
<DockPanel Name="RightDock" DockPanel.Dock="Right" Width="100"><!--RightDock--></DockPanel>
<DockPanel Name="LeftLeftDock" DockPanel.Dock="Left"> <!--LeftLeftDock-->
<StackPanel Height="auto" Visibility="Visible" Margin="5,5,5,5">
<ListBox x:Name="lbRecipe" Height="auto" Margin="0,0,0,10" BorderBrush="Blue" IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding Source={StaticResource Recipes}, XPath=recipeType, Mode=OneWay}" SelectionChanged="lbRecipe_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Height="30">
<TextBlock FontWeight="Bold">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0}">
<Binding XPath="@description" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<ListBox x:Name="lbRecipe2" Height="auto" BorderBrush="Blue" IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding Source={StaticResource Recipes}, XPath=recipeType/recipeInfo}" SelectionChanged="lbRecipe2_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Height="auto">
<TextBlock FontWeight="Bold">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0}">
<Binding XPath="@name" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</DockPanel>
<DockPanel Name="MidLeftDock" DockPanel.Dock="Left" Width="auto" Background="Black"><!--MidLeftDock-->
<!--<TextBlock Text="Large UI" Foreground="White" FontFamily="segoe UI" FontSize="90" />-->
<TextBlock FontSize="12" Foreground="White" FontFamily="segoe UI">
<TextBlock.Text>
<Binding ElementName="lbRecipe2" Path="SelectedItem.InnerText" />
</TextBlock.Text>
</TextBlock>
</DockPanel>
</DockPanel>
</Grid>
</Window>
The XML File is as follows:
<?xml version="1.0" encoding="utf-8"?>
<recipe xmnls="">
<recipeList>
<recipeType description="Breakfast" >
<recipeInfo id="b1" name="Omelet on Toast" summary="An English Breakfast" ingredients="Eggs,Butter,...">
(1) You will need 2 eggs, 1 tbspn butter...
</recipeInfo>
<recipeInfo id="b2" name="A Simple Oatmeal" summary="An English Breakfast" ingredients="Quaker Oats, Milk,...">
(1) You will need 2 cups of Quaker Oats...
</recipeInfo>
</recipeType>
<recipeType description="Lunch" >
<recipeInfo id="l1" name="Pasta" summary="An Italian Lunch" ingredients="Pasta, Tomatoes,...">
(1) You will need a packet of Pasta...
</recipeInfo>
</recipeType>
<recipeType description="Dinner" >
<recipeInfo id="d1" name="Beans and Plantain" summary="An Nigerian Dinner" ingredients="Beans,Plantain,...">
(1) You will need 4 cups of Beans...
</recipeInfo>
</recipeType>
</recipeList>
</recipe>
Any help is appreciated.
Thanks