Click here to Skip to main content
15,881,803 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Why does Microsoft do this to me Pin
Mark Salsbery13-Jul-11 11:51
Mark Salsbery13-Jul-11 11:51 
AnswerRe: Why does Microsoft do this to me Pin
Mycroft Holmes14-Jul-11 12:49
professionalMycroft Holmes14-Jul-11 12:49 
QuestionHow to draw a plus sign and triangles for buttons in WPF? Pin
Member 297299212-Jul-11 10:18
Member 297299212-Jul-11 10:18 
AnswerRe: How to draw a plus sign and triangles for buttons in WPF? Pin
Mark Salsbery12-Jul-11 10:59
Mark Salsbery12-Jul-11 10:59 
GeneralRe: How to draw a plus sign and triangles for buttons in WPF? Pin
Pete O'Hanlon12-Jul-11 11:33
mvePete O'Hanlon12-Jul-11 11:33 
GeneralRe: How to draw a plus sign and triangles for buttons in WPF? Pin
Kunal Chowdhury «IN»20-Jul-11 0:22
professionalKunal Chowdhury «IN»20-Jul-11 0:22 
AnswerRe: How to draw a plus sign and triangles for buttons in WPF? Pin
Oludayo Alli16-Aug-11 3:02
Oludayo Alli16-Aug-11 3:02 
QuestionTreeView / HierarchialDataTemplate / Generics possible in XAML? Pin
SledgeHammer0112-Jul-11 9:51
SledgeHammer0112-Jul-11 9:51 
If I have:

Dictionary<string, Dictionary<int, TestStruct>> _dict = new Dictionary<string, Dictionary<int, TestStruct>>();

and want the top level nodes to be bound to Key and the underneath nodes to be bound to Value.Name (from TestStruct), I have the following HierarchialDataTemplates:

<HierarchicalDataTemplate x:Key="TopLevelTemplate" ItemsSource="{Binding Value}">
<TextBlock Text="{Binding Path=Key}" />
</HierarchicalDataTemplate>

<HierarchicalDataTemplate x:Key="SecondLevelTemplate">
<TextBlock Text="{Binding Path=Value.Name}" />
</HierarchicalDataTemplate>

I got it to work with a data template selector like this:

public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
FrameworkElement element = container as FrameworkElement;

System.Type t = typeof(System.Collections.Generic.KeyValuePair<int, TestStruct>);

if (item.GetType() == t)
return element.FindResource("SecondLevelTemplate") as DataTemplate;

return element.FindResource("TopLevelTemplate") as DataTemplate;
}

but that kind of seems hacky... is there a way to get generics going in the HierarchialDataTemplates?

I know the usual solution is to do something like:

public class ItemCollection : List<TestStruct>

and use ItemCollection everywhere, but that doesn't really work with Dictionaries, since you are still getting KeyValuePair(K, V) from the enumerator.
QuestionCrossdomain Files in IIS Pin
Vimalsoft(Pty) Ltd12-Jul-11 0:59
professionalVimalsoft(Pty) Ltd12-Jul-11 0:59 
AnswerRe: Crossdomain Files in IIS Pin
Mark Salsbery12-Jul-11 11:03
Mark Salsbery12-Jul-11 11:03 
GeneralRe: Crossdomain Files in IIS Pin
Vimalsoft(Pty) Ltd12-Jul-11 19:30
professionalVimalsoft(Pty) Ltd12-Jul-11 19:30 
QuestionHide application Icon from alt+tab Pin
John-ph10-Jul-11 18:23
John-ph10-Jul-11 18:23 
AnswerRe: Hide application Icon from alt+tab Pin
Mark Salsbery11-Jul-11 10:12
Mark Salsbery11-Jul-11 10:12 
QuestionSilverlight Navigation Pin
sudheesh kumar s9-Jul-11 20:39
sudheesh kumar s9-Jul-11 20:39 
AnswerRe: Silverlight Navigation Pin
Abhinav S9-Jul-11 20:45
Abhinav S9-Jul-11 20:45 
QuestionWPF Glass problem Pin
Mehdi Ghiasi9-Jul-11 6:34
Mehdi Ghiasi9-Jul-11 6:34 
SuggestionRe: WPF Glass problem Pin
Oludayo Alli16-Aug-11 3:15
Oludayo Alli16-Aug-11 3:15 
Question'LayoutRoot' suddenly recognized [modified] Pin
Neo101018-Jul-11 22:01
Neo101018-Jul-11 22:01 
QuestionBasic Question about ADO.NET in Silverlight Pin
AmbiguousName7-Jul-11 2:25
AmbiguousName7-Jul-11 2:25 
AnswerRe: Basic Question about ADO.NET in Silverlight Pin
Mycroft Holmes7-Jul-11 21:57
professionalMycroft Holmes7-Jul-11 21:57 
AnswerRe: Basic Question about ADO.NET in Silverlight Pin
Mark Salsbery8-Jul-11 5:53
Mark Salsbery8-Jul-11 5:53 
AnswerRe: Basic Question about ADO.NET in Silverlight Pin
Abhinav S9-Jul-11 20:42
Abhinav S9-Jul-11 20:42 
QuestionPropertyChange doesn't refresh DataTemplate inside ItemsControl Pin
John-ph7-Jul-11 2:11
John-ph7-Jul-11 2:11 
AnswerRe: PropertyChange doesn't refresh DataTemplate inside ItemsControl Pin
SledgeHammer017-Jul-11 14:01
SledgeHammer017-Jul-11 14:01 
QuestionCalculation of value of DependencyProperty [modified] Pin
devvvy6-Jul-11 23:56
devvvy6-Jul-11 23:56 

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.