Click here to Skip to main content
15,890,527 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: silverlight - backgroundworker process Pin
Pete O'Hanlon31-Aug-11 23:18
mvePete O'Hanlon31-Aug-11 23:18 
GeneralRe: silverlight - backgroundworker process Pin
arkiboys31-Aug-11 23:38
arkiboys31-Aug-11 23:38 
GeneralRe: silverlight - backgroundworker process Pin
Pete O'Hanlon1-Sep-11 0:12
mvePete O'Hanlon1-Sep-11 0:12 
GeneralRe: silverlight - backgroundworker process Pin
arkiboys1-Sep-11 0:16
arkiboys1-Sep-11 0:16 
QuestionWindows Phone Pin
arkiboys31-Aug-11 7:43
arkiboys31-Aug-11 7:43 
QuestionMaster-Details binding of 2 related tables Pin
bitwise.csc31-Aug-11 2:29
bitwise.csc31-Aug-11 2:29 
AnswerRe: Master-Details binding of 2 related tables Pin
Wayne Gaylard31-Aug-11 4:32
professionalWayne Gaylard31-Aug-11 4:32 
GeneralRe: Master-Details binding of 2 related tables Pin
bitwise.csc31-Aug-11 4:59
bitwise.csc31-Aug-11 4:59 
Wayne, firstly thank you so much for your efforts.


Seriously, I would never thought that using DataSets in WPF projects is not the best solution.
So, by now a got such code:

C#
public DataSet GetDataSet()
 {
 string queryCatStr = @"SELECT * FROM [Category]";
 string queryProdStr = @"SELECT * FROM [Products]";

 DataSet ds = new DataSet();

 SQLConnection dbConn = new SQLConnection("conn_str"))
 dbConn.Open(); 
 SQLCommand cmd = new SQLCommand(dbConn);

 cmd.CommandText = queryCatStr;
 SQLDataAdapter da = new SQLDataAdapter(cmd);
 da.Fill(ds, "Categories");

 cmd.CommandText = queryProdStr;
 da.Fill(ds, "Products");

 DataRelation drCat2Prod = new DataRelation("Cat2Prod", ds.Tables["categories"].Columns["CategoryID"], ds.Tables["Products"].Columns["CategoryID"]);
 ds.Relations.Add(drCat2Prod);
 
 return ds;
 }


 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
 ds = GetDataSet();
 this.DataContext = ds.Tables["Category"];
 this.treeCategories.DisplayMemberPath = "CategoryName";
 }



HTML
<TreeView x:Name="treeCategories" ItemsSource="{Binding}" />
...

<ListView x:Name="lstProducts" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Cat2Prod}" />


And now I just can't understand why this binding doesn't work as I expected - ListView contains products only for the first category and doesn't update contents when user selects another item in TreeView.


If I used ObservableCollection as a data source for the application, I would take care about initialization and synchronizing objects in the collection with data base. But ADO cand do it behind the scene as I think.

Even If I tried to init ObservableCollection of CategoryObjects with ProductsList contained in each one, I would make as many SQL queries to DB as many Categories I got in CategoriesTable.
Moreover, I should keep Data Base up-to-date, updating it manually. It seems to me this is not a good solution for me. But may be I'm wrong.
GeneralRe: Master-Details binding of 2 related tables Pin
Pete O'Hanlon31-Aug-11 5:15
mvePete O'Hanlon31-Aug-11 5:15 
GeneralRe: Master-Details binding of 2 related tables Pin
bitwise.csc31-Aug-11 5:21
bitwise.csc31-Aug-11 5:21 
QuestionNavigate in Frame from code Pin
yesu prakash30-Aug-11 19:34
yesu prakash30-Aug-11 19:34 
AnswerRe: Navigate in Frame from code Pin
Mycroft Holmes30-Aug-11 22:24
professionalMycroft Holmes30-Aug-11 22:24 
QuestionData binding model: "Main->Details" Pin
bitwise.csc29-Aug-11 3:14
bitwise.csc29-Aug-11 3:14 
AnswerRe: Data binding model: "Main->Details" Pin
Wayne Gaylard29-Aug-11 3:24
professionalWayne Gaylard29-Aug-11 3:24 
GeneralRe: Data binding model: "Main->Details" Pin
bitwise.csc29-Aug-11 3:30
bitwise.csc29-Aug-11 3:30 
GeneralRe: Data binding model: "Main->Details" Pin
Wayne Gaylard29-Aug-11 3:42
professionalWayne Gaylard29-Aug-11 3:42 
GeneralRe: Data binding model: "Main->Details" [modified] Pin
bitwise.csc29-Aug-11 3:51
bitwise.csc29-Aug-11 3:51 
GeneralRe: Data binding model: "Main->Details" Pin
bitwise.csc29-Aug-11 11:14
bitwise.csc29-Aug-11 11:14 
GeneralRe: Data binding model: "Main->Details" Pin
Wayne Gaylard29-Aug-11 22:03
professionalWayne Gaylard29-Aug-11 22:03 
QuestionTutorial to display Google Maps using WPF-WCF Pin
Member 819216328-Aug-11 5:24
Member 819216328-Aug-11 5:24 
AnswerRe: Tutorial to display Google Maps using WPF-WCF Pin
Abhinav S28-Aug-11 22:19
Abhinav S28-Aug-11 22:19 
QuestionRound corner border not that easy Pin
Zapacila27-Aug-11 22:36
Zapacila27-Aug-11 22:36 
QuestionA Combobox size within menu [modified] Pin
Saksida Bojan27-Aug-11 6:35
Saksida Bojan27-Aug-11 6:35 
AnswerRe: A Combobox size within menu Pin
Abhinav S27-Aug-11 7:02
Abhinav S27-Aug-11 7:02 
GeneralRe: A Combobox size within menu Pin
Saksida Bojan27-Aug-11 8:08
Saksida Bojan27-Aug-11 8:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.