Question about "advanced" databinding
I'll try to make this as detailed as possible. I am writing an application that requires me to pull out multiple different tables from a database. Basically, I'm pulling out 21 different tables with a wide range of rows inside those tables (from 0-1000's). The 21 tables are 21 different types of tests, and the data stored in those tables are all of the different tests of that type and the values gathered from the test. I am attempting to display the data in a fashion like this:
Name of BaseTest (expander)
ListView (Has ALL the test from ALL the different test types)
Name of SecondTest(expander)
ListView....
(Continued for the 21 tests done)
My problem is that I am fumbling with how to go about storing/binding the data. I've spent all afternoon playing around with using an array of datatables, a big dataset, an arraylist, and I even tried writing a function to go and bind the data to the right source. I've got single source databinding down really well, but now that I'm into single source with multiple different sets of values, I'm in over my head again.
Is there a way to pull paths from one of these lunker datasets so I can reference them in the XAML tags?
e.g:
<Page.Resources>
<Style TargetType="{x:Type ListBoxItem}" x:Key="ResultsItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Grid>
<Expander Name="exp_Info" Header="{Binding Path=Name1}">
<ListView Height="300" Name="lv_ExpandedInfo">
<TextBlock>
<TextBlock Text="{Binding Path=InnerTable.Name1}"/>
<TextBlock Text="{Binding Path=InnerTable.ID}"/>
<TextBlock Text="{Binding Path=InnerTable.Result}"/>
<TextBlock Text="{Binding Path=InnerTable.Result2}"/>
</TextBlock>
</ListView>
<!--<Frame Source="{Binding Path=Description}" /> -->
</Expander>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Page.Resources>
Or something similar to that manner? I'm not sure what the best way is for doing this.
The C# running in the back looks like this (edited):
DataSet dsTables = new DataSet(); //new dataset
foreach (DataRow row in dtContainingAllTables.Rows)
{
String sqlGetCommand = "get stuff from db"
DataTable dtTemp = databaseObj.SQLSelect_Generic(sqlGetSpecificMetrics);
try
{
int iTemp = (Convert.ToInt32(row["ID"]) - 1);
//if the table is empty don't put it in the set
if (dtTemp.Rows.Count == 0)
Console.Out.Write("No data in table\n");
else
dsTables.Tables.Add(dtTemp);
}
catch (Exception)
{
//
}
}
listboxOnPage.DataContext = dsTables;
Just an added note, I've thought about making a class to hold the test items, and do binding that way, but I feel that that would kill the applications speed having to go and make all those objects and then load them in. (All of this is being controlled by a selected item, which could change instantly.. so the data does have to move around fairly rapidly)
Any help would be greatly appreciated.. I'm really kind of stuck on this one, and I need it to work to be able to move on. If there is something I missed please don't be afraid to point it out! :-P
Thanks in advance,
~Elliot

