Wpf setting events in nested list throws null reference exception?

I just encountered the same sort of problem (mine was with a comboBox and the LostFocus event ). I'm able to work around it by moving the Event handling bit to a style in my view's ResourceDictionary .

Up vote 0 down vote favorite share g+ share fb share tw.

I'm trying to drop a file into a textbox in order to set the content of the textbox with the path of the file (second DataTemplate). So I added the event DragOver on my textBox. But I get an Null reference exception.

I tried many other events and got the same error. In the first dataTemplate, events are just working fine. This may be because my textbox is in a nested list.

But I am not sure. Any idea? Wpf events list xaml nested link|improve this question asked Oct 28 '11 at 4:11brako11.

– AngelWPF Oct 28 '11 at 6:56 no I don't reach the breakpoint. My application is crashing immediately, without dragging anything. The Call stack shows that the exception is throwed by Windows.

FrameworkTemplate. LoadTemplateXaml(...) – brako Oct 28 '11 at 15:01 You could try to comment out large regions of the template and slowly add them back in until you find the offending lines. – Erno Nov 25 '11 at 19:34.

I just encountered the same sort of problem (mine was with a comboBox and the LostFocus event). I'm able to work around it by moving the Event handling bit to a style in my view's ResourceDictionary. Try something like this.

Yes, the idea is good. Make style as a static resource resolves a part of the problem. But I can't make a listbox select the right template according to the type of the binded object.

– brako Jan 30 at 21:33.

Thanks, Nested data templates are not working properly with . NET 4.0 You can read more about this bug : Official bug report My workaround : Create my own data template selector : public class TemplateSelector : DataTemplateSelector { public DataTemplate UnknownTemplate { get; set; } public override DataTemplate SelectTemplate(object item, DependencyObject container) { if (item is PropertiesUnkownModel) { return UnknownTemplate; } return UnknownTemplate; } } Template selector in xaml : and how I use it.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions