hello friends,
I want to filter xmldata present as a item source of dynamically generated stack panel consisting of textblock,combobox and textbox.What i want is since textblock displays the selected element(which i have already figured out) user should select a filter criteria from the combobox and add text to the textbox and based on 3 filters,,it should filter and should display the filtered content.On searching the internet i found that linq to xml was a feasilble way.
here is the xaml
codexaml
<ListView Height="222" HorizontalAlignment="Left" Margin="341,24,0,0" Name="listView1" VerticalAlignment="Top" Width="290" removed="Green"
AllowDrop="True"
DragDrop.Drop="listview_drop"
DragDrop.DragEnter="treeview_dragenter" ItemsSource="{Binding XPath=self::*}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" x:Name="stc">
<TextBlock Text="{Binding Path=Name}" Margin="0,0,3,0" x:Name="abc"/>
<ComboBox Margin="0,0,3,0" x:Name="cbox1">
<ComboBoxItem Content="Less Than"/>
<ComboBoxItem Content="Greater Than"/>
<ComboBoxItem Content="Equals"/>
</ComboBox>
<TextBox Margin="0,0,3,0" Width="50" x:Name="textbox1" />
<Button x:Name="but1" Height="25" Width="35" Click="click" Content="gen" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
And the c# code behind
private void click(object sender, RoutedEventArgs e)
{
var button = sender as Button;
var parent = button.Parent as FrameworkElement;
var textBox = parent.FindName("textbox1") as TextBox;
var textbl = parent.FindName("abc") as TextBlock;
var com=parent.FindName("cbox1")as ComboBox;
Xelement filter= (Xelement)((XmlDataProvider)Resources["xmlDataProvider"]).Data;
}
My problem is that on working with xelement,Iam getting a invalid type exception that it cannot convert system.xml.xmldocument to system.xml.linq .