Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Exactly when should you call InitializeComponent()?
Message
De
31/07/2008 04:06:10
 
 
À
30/07/2008 11:46:01
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Divers
Thread ID:
01335283
Message ID:
01335446
Vues:
13
>when is the right time to call InitializeComponent();?
>
>
>
>     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();
>
>            SketchX0 = canvas1.Width / 2;
>            SketchY0 = canvas1.Height / 2;
>            SketchBoltCirRad = canvas1.Width / 2 * .7;
>
>
>            CoordinateGrid.ItemsSource = CurrentHolePattern.HoleList;
>
>            RedrawScreen();
>
>
>        }
>
I'd lean towards putting it at the top - that way you're less likely to be caught out attempting to access objects that haven't been instantiated ....
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform