Note that there are some explanatory texts on larger screens.

plurals
  1. PODataGridView XElement filtering via Textbox text
    text
    copied!<p>here is my "project":</p> <p><img src="https://i.stack.imgur.com/OvXoo.jpg" alt="project"></p> <p>What I'm trying to do is to load data from an external .xml file into the DataGrid:</p> <pre><code>XElement Persons = XElement.Load(@"d:\persons.xml"); dataGrid1.DataContext = Persons; </code></pre> <p>It works just fine, but here is an issue which I can't figure out: at the top of DataGrid you can see TextBox so what I need is to use the textBox1.text as a data filter for DataGrid. Let's say if user input letter "a", in DataGriw we should see only 2 rows, with name pAul and row with country russiA, cause both rows contain letter "a" in it's data. If you will also help me to include and exclude some columns abilitiness for search it would be just brilliant. And finally, if user click on the row he found using a search button - data from the sells should be placed to the labels at the right. I also would be happy to know how to load data of the selected row which is not actually shows in DataGrid. Let's say if in xml file we have data about salary, but we do not shown it in DataGrid and we need it to be loaded to the 4th label when user do a row selection. Here is my XAML:</p> <pre><code>&lt;Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="679" Width="1137"&gt; &lt;Grid Height="645" Name="grid1" Width="1119"&gt; &lt;DataGrid Height="300" ItemsSource="{Binding Path=Elements[person]}" Margin="26,42,839,297" Name="dataGrid1" Width="250"&gt; &lt;DataGrid.Columns&gt; &lt;DataGridTextColumn Binding="{Binding Path=Element[name].Value}" Header="Name" /&gt; &lt;DataGridTextColumn Binding="{Binding Path=Element[country].Value}" Header="Country" /&gt; &lt;DataGridTextColumn Binding="{Binding Path=Element[age].Value}" Header="Age" /&gt; &lt;/DataGrid.Columns&gt; &lt;/DataGrid&gt; &lt;TextBox Height="24" HorizontalAlignment="Left" Margin="26,12,0,0" Name="textBox1" VerticalAlignment="Top" Width="250" /&gt; &lt;Label Content="Name goes here on row select" Height="28" HorizontalAlignment="Left" Margin="307,28,0,0" Name="label1" VerticalAlignment="Top" Width="188" /&gt; &lt;Label Content="Country goes here on row select" Height="28" HorizontalAlignment="Left" Margin="307,72,0,0" Name="label2" VerticalAlignment="Top" Width="188" /&gt; &lt;Label Content="Age goes here on row select" Height="28" HorizontalAlignment="Left" Margin="307,120,0,0" Name="label3" VerticalAlignment="Top" Width="188" /&gt; &lt;/Grid&gt; </code></pre> <p></p> <p>Please talk to me like to the absolute beginner, cause it's hard for me to understand when you use something extra smart. Step by step is highly appreciated. Thank you...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload