i have a linq that i bind the results to my listbox. what i want to do is in my page i want a value of an element from that linq result to be bound on a control (textblock) that is outside my <ListBox.ItemTemplate><DataTemplate>
here is my linq:
and here is my xaml:Code:var data = from query in loadedData.Descendants("article") where query.Attribute("Title").Value == articleNo select new article() { Title = query.Attribute("Title").Value, SubTitle = query.Attribute("SubTitle").Value, Content = query.Attribute("Content").Value }; listBox.ItemsSource = data;
i need to bind the SubTitle to a textblock outside of my listbox. is there anyway for me to bind a linq result to a control even if i have already put the linq's result to a listbox's itemsource? like <TextBlock Text="<Binding SubTitle"> only?Code:<ListBox x:Name="listBox"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Height="Auto" HorizontalAlignment="Left" Name="stackPanel1" VerticalAlignment="Top" Width="auto"> <TextBlock Height="Auto" Name="txSubTitle" Text="{Binding SubTitle}" FontSize="32" Foreground="#FFFFFF" Margin="12,0,0,0" TextWrapping="Wrap" /> <TextBlock FontSize="26" Height="Auto" Name="txContent" Text="{Binding Content}" Margin="12,0,0,0" Foreground="#FF7D97AE" TextWrapping="Wrap" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox>

Reply With Quote

