Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
About my WPF app to draw a Bolt Hole Pattern.
Message
From
31/07/2008 14:02:43
 
 
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Miscellaneous
Thread ID:
01334102
Message ID:
01335590
Views:
19
>>>>>>Well... I found two errors to start with.
>>>>>>
>>>>>>
     private void NotifyPropertyChanged(String info)
>>>>>>        {
>>>>>>        if (PropertyChanged != null)
>>>>>>          {
>>>>>>          PropertyChanged(this, new PropertyChangedEventArgs(info));
>>>>>>          //CollectionChanged was null commented it off
>>>>>>          //CollectionChanged(this, new CollectionChangeEventArgs(CollectionChangeAction.Refresh, this.HoleList));
>>>>>>          }
>>>>>>        }
>>>>>>
>>>>>>Second was that repaint screen was not getting called. You are binding to CurrentHolePattern so:
>>>>>>
>>>>>>
CurrentHolePattern.PropertyChanged += new PropertyChangedEventHandler(CurrentHolePattern_PropertyChanged);
>>>>>>
>>>>>>This looks like it works:
>>>>>>
>>>>>>
    public Window1()
>>>>>>      {
>>>>>>
>>>>>>      HolePatterns = new ObservableCollection<HolePattern>();
>>>>>>      HolePatterns.CollectionChanged += new NotifyCollectionChangedEventHandler(HolePatterns_CollectionChanged);
>>>>>>
>>>>>>      CurrentHolePattern = new HolePattern();
>>>>>>      CurrentHolePattern.PatternName = "Test Pattern Name";
>>>>>>
>>>>>>      //-- Set some default values for the UI
>>>>>>      CurrentHolePattern.BoltCirDia = 12.0;
>>>>>>      CurrentHolePattern.HoleCount = 6;
>>>>>>      CurrentHolePattern.StartAngle = 0;
>>>>>>
>>>>>>      HolePatterns.Add(CurrentHolePattern);
>>>>>>
>>>>>>      InitializeComponent();
>>>>>>      CurrentHolePattern.PropertyChanged += new PropertyChangedEventHandler(CurrentHolePattern_PropertyChanged);
>>>>>>
>>>>>>      SketchX0 = canvas1.Width / 2;
>>>>>>      SketchY0 = canvas1.Height / 2;
>>>>>>      SketchBoltCirRad = canvas1.Width / 2 * .7;
>>>>>>
>>>>>>      CoordinateGrid.ItemsSource = CurrentHolePattern.HoleList;
>>>>>>
>>>>>>      RedrawScreen();
>>>>>>      }
>>>>>>
>>>>>>    void CurrentHolePattern_PropertyChanged(object sender, PropertyChangedEventArgs e)
>>>>>>      {
>>>>>>      RedrawScreen();
>>>>>>      //RepaintScreen();  Repaint doesn't add new holes.
>>>>>>      }
>>>>>>
>>>>>
>>>>>Dang. Just read this. I pulled in Matt's code last night and had made *exactly* the same changes that you pointed out. But then it would not run - I got a XMLParseException:
>>>>>Cannot create instance of 'Window1' defined in assembly 'WpfApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error in markup file 'Window1.xaml' Line 1 Position 9.
>>>>>
>>>>>Didn't have time to look at it any more and don't now either but it's still giving that error unless the RedrawScreen() line is commented out in the event handler.
>>>>>???
>>>>>Regards,
>>>>>Viv
>>>>
>>>>Did you put the
>>>>
>>>>CurrentHolePattern.PropertyChanged += new PropertyChangedEventHandler(CurrentHolePattern_PropertyChanged);
>>>>
>>>>before the
>>>>
>>>>InitializeComponent();
>>>>
>>>>by any chance? That will throw that error.
>>>
>>>Very possibly. But, as I just mentioned to Matt, without thinking I pasted his newer version over the top of the one with my changes so now I'll never know for sure. IAC I'll know what to check if I make the same mistake in the future!
>>>Thanks,
>>>Viv
>>
>>The only reason it came to mind is that I made that mistake myself.<g>
>
>Did you actually deduce the cause of the error from the exception message? To me it provided no clue at all!

Ya I hate that error message it's about the same as saying "Something Wrong"

But one of the things I look for when I see it, is for references to the XAML prior to InitializeComponent(); I also look to see what I changed from when it was working.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform