Click here to Skip to main content
15,886,026 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Installation Requirements Pin
arkiboys14-Aug-11 8:57
arkiboys14-Aug-11 8:57 
QuestionBinding in two way mode from a XML file to a combobox in usercontrol [modified] Pin
npuleio13-Aug-11 3:57
npuleio13-Aug-11 3:57 
QuestionAccessing function on Usercontrol hosted from Window in MVVM and C# Pin
Alisaunder12-Aug-11 5:55
Alisaunder12-Aug-11 5:55 
AnswerRe: Accessing function on Usercontrol hosted from Window in MVVM and C# Pin
SledgeHammer0112-Aug-11 6:52
SledgeHammer0112-Aug-11 6:52 
GeneralRe: Accessing function on Usercontrol hosted from Window in MVVM and C# [modified] Pin
Alisaunder12-Aug-11 7:25
Alisaunder12-Aug-11 7:25 
GeneralRe: Accessing function on Usercontrol hosted from Window in MVVM and C# Pin
SledgeHammer0112-Aug-11 7:42
SledgeHammer0112-Aug-11 7:42 
GeneralRe: Accessing function on Usercontrol hosted from Window in MVVM and C# Pin
Alisaunder12-Aug-11 8:12
Alisaunder12-Aug-11 8:12 
GeneralRe: Accessing function on Usercontrol hosted from Window in MVVM and C# Pin
SledgeHammer0112-Aug-11 8:38
SledgeHammer0112-Aug-11 8:38 
Haha... yeah, MVVM is a learning curve on top of the WPF learning curve. Trust me though, I come from the MFC / C++ world and did a bit of time in the C# / Winforms world... the WPF / MVVM way is by far the best. It results in *really* clean code.

Anyways...

Your data structure should kind of try to closely mirror how you want it in the tree. Obviously we aren't going to be modifying the alphabet any time soon, so we have 26 root nodes. I'd probably try to store it in something like:

public class ContactCollection : ObservableCollection<Contact>

The reason you need to do that is because XAML doesn't work well with generics.

SortedDictionary<char, ContactCollection>

so you'll populate the sorted dictionary with keys 'A' through 'Z' and new up an ContactCollection as the value. Then populate each ContactCollection with the names matching that letter. There is a little known trick to sort the ObservableCollections after you populate them. You derive a class from ObservableCollection<t> and add a method like this:

C#
public void Sort(Comparison<T> comparison)
{
    ((List<T>)Items).Sort(comparison);
    OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}


Then your HierachialDataTemplate would just specify Key as the top level display binding and Values as the ItemsSource. Another HierachialDataTemplate would be typed for Contact and have the name as the display value.

This all might not make sense now, but once you get going, it will.
GeneralRe: Accessing function on Usercontrol hosted from Window in MVVM and C# [modified] Pin
Alisaunder12-Aug-11 10:26
Alisaunder12-Aug-11 10:26 
GeneralRe: Accessing function on Usercontrol hosted from Window in MVVM and C# Pin
SledgeHammer0112-Aug-11 11:01
SledgeHammer0112-Aug-11 11:01 
GeneralRe: Accessing function on Usercontrol hosted from Window in MVVM and C# [modified] Pin
Alisaunder12-Aug-11 13:32
Alisaunder12-Aug-11 13:32 
GeneralRe: Accessing function on Usercontrol hosted from Window in MVVM and C# Pin
Alisaunder13-Aug-11 11:25
Alisaunder13-Aug-11 11:25 
GeneralRe: Accessing function on Usercontrol hosted from Window in MVVM and C# Pin
SledgeHammer0113-Aug-11 11:49
SledgeHammer0113-Aug-11 11:49 
GeneralRe: Accessing function on Usercontrol hosted from Window in MVVM and C# Pin
Alisaunder13-Aug-11 15:09
Alisaunder13-Aug-11 15:09 
GeneralRe: Accessing function on Usercontrol hosted from Window in MVVM and C# Pin
SledgeHammer0113-Aug-11 15:35
SledgeHammer0113-Aug-11 15:35 
GeneralRe: Accessing function on Usercontrol hosted from Window in MVVM and C# Pin
Alisaunder14-Aug-11 14:36
Alisaunder14-Aug-11 14:36 
GeneralRe: Accessing function on Usercontrol hosted from Window in MVVM and C# Pin
SledgeHammer0114-Aug-11 15:04
SledgeHammer0114-Aug-11 15:04 
GeneralRe: Accessing function on Usercontrol hosted from Window in MVVM and C# Pin
Alisaunder15-Aug-11 22:01
Alisaunder15-Aug-11 22:01 
Questionsiilverlight 4 - listbox to have Tag Pin
arkiboys12-Aug-11 4:32
arkiboys12-Aug-11 4:32 
AnswerRe: siilverlight 4 - listbox to have Tag Pin
#realJSOP12-Aug-11 6:32
mve#realJSOP12-Aug-11 6:32 
Questionsilverlight listbox - fill colour Pin
arkiboys12-Aug-11 4:24
arkiboys12-Aug-11 4:24 
AnswerRe: silverlight listbox - fill colour Pin
Mycroft Holmes12-Aug-11 23:44
professionalMycroft Holmes12-Aug-11 23:44 
GeneralRe: silverlight listbox - fill colour Pin
arkiboys13-Aug-11 22:10
arkiboys13-Aug-11 22:10 
QuestionWPF Webbrowser bot releasing PDF file -- Help Needed Pin
pal2ashish12-Aug-11 0:36
pal2ashish12-Aug-11 0:36 
AnswerRe: WPF Webbrowser bot releasing PDF file -- Help Needed Pin
Alisaunder12-Aug-11 14:14
Alisaunder12-Aug-11 14:14 

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.