How do others use and set the 'Grid's' properties in a WPF application?

Granted I haven’t looked at Delphi since the original XE but unless great strides have been made encompassing XAML etc., it’s probably time for its complate retirement! As many have already said here, XAML provides abilities and an ease of use factor that makes the VCL, ( A great idea in its time ), almost as bad as the MFC!

I do understand how the ‘Grid’ of an XAML based form replaces the VCL form’s inherent surface, allowing other controls and even direct text and/or graphics to be added, but I’m a little confused by how it and its properties should be set and used in relationship to its underlying parent!

At first glance, it appears to me that none of its properties even need to be bothered with as long as those of its parent are set correctly and show thru, however I suspect that in combination they may actually add something new and interesting to the design set. So I’d be interested in hearing more about it from those who have been using XAML for awhile. Thanx in advance!

Hello,

Grid in WPF is a really cool container control for creating any possible kind of complex UI layouts.
It is so popular that usually used as first level container in any new WPF window

 
   
   
 

Creating layouts using Grid takes 2 steps. At the first step you need to specify count of rows and columns inside the Grid


    
    
         
        
        
        
        
    
        
    
    
        
        
        
        
        
    

    

And at the second step we will add other UI controls and bind them to the proper grid columns and rows. Binding exact control to the Grid column and row is made via using so-called Attached Properties. You can find a lot about them in the internet, but in general attached properties allow us to specify some “container object” property values from its “contained object”.


  ...

  Notes:

  


I’ll attach here xaml source and screenshot how it looks inside VS design editor.
Hope this will help you.

If you will get any questions I’ll be happy to answer

Thanx so muxh Alexk! I wasn’t percieving the grid as a conainer obect but merely XAML’s notion of the Delphi Canvas! And having it show up automatically on every XAML form design surface enforced that notion!

Must I always keep it however? Is it necessary as a base object, or can I delete it and simply use the form as before. Or will this cause problems down the line? And if I DO keep it, exactly how does it effect the base form’s design? Another words is is best to use it to set color and other base properties, or if not actually using it, set the base form’s properties and make the Grid invisible?

The Grid is nothing like the Delphi Canvas. Canvas is just a dumb drawing surface. Grid is one of the Layout type containers. There are others. Like StackPanel and WrapPanel.

NOT every form needs to have a Grid. It gets generated as the default layout container by templates, but it doesn’t have to be used at all. What you use depends on your needs. You choose one based on what kind of a layout you need on your form.

There ALSO is a Canvas in WPF/Silverlight. THAT is analogous to the Delphi one.

If you are concerned about how things look, per you question about setting color, you want to look at default Styles and Themes, but some properties DO get inherited from their parent.

I don’t think there even IS a Form in WPF and Silverlight.

If you are just starting, I would highly recommend that you learn the MVVM pattern also. That really let’s you leverage the way Xaml works.

Oh and one other cool thing about Xaml. If you have “child” controls, you can EASILY cut and paste them into a new UserControl and then just reference them in the parent. That is REALLY easy to do compare to trying to make a Delphi Component.

Oh yes! I already see how much of an improvement it is over the old VCL! In any case you answered my question. And based on what you have told me I’ll most likely make myself a template for a simple WPF project that doesn’t include the Grid right from the start. That way I can allieviate any overhead it adds to a small app if not needed. In fact, I’m sure I’ll be creating a whole lot of templates geared to the way I design different visual styles!

You should really study the Styles and Themes in Xaml. (I THINK WPF does Themes. I’m not sure because I code almost exclusively Silverlight which is STILL the best framework available, imho)

Rather than make templates.

I have a template that lays out a project with the expected pieces/parts I want with the proper folder structure I want and pieces/parts to support MVVM.

I’m not sure you want Templates. I think you might just want a project of User Controls.

Doesn’t matter what it is called because on can even set default or special starting points for projects and call them Samples! I had a lot of them in Delphi long ago.

Is SILVERLIGHT Win 8 only? And exactly what is WVVM? I don’ t want to use any techniques that cannot be used under all Win OSs possible. Win 8 won’ t interest me for 2-3 years.

No SL is not Win8 only. In fact, it isn’t Win8 at all. It will run on all the OSes from XP on. But on Win8, it will only runs on a full Windows Pro and only on the “legacy desktop”.

Win 8 apps ONLY run on Win 8. But basically all the good stuff from WPF/Silverlight were moved into Windows 8. EXCEPT for the cross-platform piece. AND a lot of controls, etc.

SL runs IN the browser by default, but also has an Out Of Browser (OOB) mode which has more access to the hardware and keeps a copy on the users local hard disk. There is also a built-in mechanism for OOB to get automatic or manual updates.

So most anything you would learn on SL will eventually apply to Win 8. Also, if you make apps for Windows Phone 7, that is ONLY Silverlight. Windows Phone 8 can run WP 7 apps also.

MVVM is a really good Pattern. It stands for Model, View, ViewModel. Basically you can keep your Model (the data), the View (the UI), and the ViewModel (your app specific object classes) completely separate from each other. You can even have the 3 is separate assemblies that don’t know ANYTHING about each other. (well, actually, I guess the Viewmodel usually knows about the Model because it gets its data from there).

Once you do that pattern, it makes your life so much more easy. And SL works BEST when you do this pattern.

There are lots of write-ups and videos on the web about it. Some are here:

http://msdn.microsoft.com/en-us/silverlight/bb187358.aspx

MVVM is a really good pattern that works with WPF/Silverlight and Win8 and would even be somewhat helpful in non-Windows environments, but probably not as much in non-Windows places.