Our Blogs
English
Español
Skip Navigation Links
News
Our Team
Mentoring
Ken Spencer
Go to home page
Go Search

 
Categories
There are no items in this list.
Other Blogs
There are no items in this list.

Our Blogs > English > Ken Spencer
ObservableCollection

For WPF, the ObservableCollection<(Of <(T>) makes it easy to create classes that are aware of changes, inserts, and deletions. This class automatically works with the UI to notify it of these changes.

You can use this class in the User Interface collection. The easiest way to use it is to create an instance of the ObservableCollection and pass your business layer class to the constructor.

Read more about this class at: http://msdn.microsoft.com/en-us/library/ms668604.aspx

 

Ken

PDC In LA

Well, the Microsoft PDC is mind blowing again! We can see the future unfolding in front of us.  Here are some of the things that i am really excited about:

Surface. Wow. Microsoft has hit the future with Surface. Playing with the demos and real applications is mind blowing. Check out http://www.microsoft.com/surface/index.html for some ideas. Then go search YouTube for Surface.  And don't expect to see Surface just on the coffee table. Wall displays, hand helds, more more more.

Cloud Stuff. All the buzz about the cloud stuff is cool. This is just laying the ground work for the future infrastructure we will need. the cloud will be great but it will take some time.

Windows 7. Windows keeps getting better and better. I have been a long time Vista user and with the next version its just moving rapidly ahead with the evolution of this awesome OS.  I notice some blogs out there saying they hate it already. Fits with the political season where you hate something without knowing anything about it. Come on and lets see what's really cooking. No software gets perfect without improving it over time. I think we call that Agile now.

 

Architect Connections - October 6 - 8, 2008

If you were in my Build / Deploy session and want the demos, please email them and i will send them along.

Thanks for all the lively discussion during the session.

Ken

Rebuilding Vista Systems is getting easy

The other week i rebuilt my machine with a new 320GB 7200 rpm drive.
Easy upgrade steps:
1) Acquire new drive
2) Take out old drive and put in new drive
3) Install Vista with SP1
4) Install apps (sql 2005, office 2007, vs 2005, vs 2008)
5) Put old drive into external usb enclosure
6) Plug external drive into machine
7) drag and drop files from old drive onto new drive (do just before going to sleep)
8) Enjoy new faster and bigger machine

I was surprised that this only took about 2-3 hours of my active time. I started it on a sat morning about 10 or so. Then during the day i just periodically fed it disks. Then started the file copy.

Moore's law and better software are now making even rebuilding a machine easier.

Vista's Easy Transfer is also very helpful for transfering settings and files when moving to another system.

http://www.microsoft.com/windows/windows-vista/features/easy-transfer.aspx

Im a PC!
Well, color me PC!
 
I am a PC and have always been.

I love the new ads and its about time too.

Ken

Background Worker Process

Ah, the sky is falling. Spencer is writing on c#. Guess we all must make a living.

I have a winform app that i wrote for a client. It uses the background worker process to do its magic.

So far, so good. I wanted to put in a hold process in a loop so the loop would hold till the current background process finished. I tried putting a do nothing loop like so:

  while (HoldExecute)
  {
      System.Threading.Thread.Sleep(1000);
  }

but the background thread never ran. Then i had a brainstorm. Good old doevents. Changed this to the following and voila it works:

  Application.DoEvents();
  while (HoldExecute)
  {
      Application.DoEvents();
      System.Threading.Thread.Sleep(1000);
  }

now the app runs the outer loop (not shown) and when the background worker finsihes it sets the HoldExecute variable to false and the inner loop terminates.

This should work in vb too.

Auto Generation of WPF Forms from SQL Server databases
One of the things thats painful in development is just dragging fields over to a form and dropping them. For one form, big deal. But starting  new project and creating 100s of forms is not fun. Billy Hollis showed me some code he wrote to generate a wpf form from a table.
So, i bit the bullet yesterday and wrote a wpf code generator. You simply enter a connection string then click Go and seconds later you have your xaml files.
Of course, the tool needs lots of work. I may update it for a sql magazine article soon.
Heres how it works:
Configuration folder: Create a config folder c:\WPFTemplates. This contains one xaml file with the following code:
<Window x:Class="$$$Window"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <Grid >
$$Rows$$
    </Grid>
</Window>
The $$$Window placeholder is replaced by the tool with a valid .NET name based on the table name.
The $$Rows$$ placeholder is replaced with the form fields generated by the tool.
 
The xaml files are written to the folder: C:\Temp\WPFForms
The tool uses the MetaDataSQLServerSimple class to extract data from SQL Server.
 
You can download the tool source code from here: http://blogs.solidq.com/EN/DevCave/Files/SpencersWPFGenerator.zip
 
Enjoy and send me any changes if you would and i will repost this.
 
Also, check out my other code generator at http://blogs.solidq.com/EN/DevCave/Lists/Posts/AllPosts.aspx . One thing i would like to do is automatically wire up databinding for the generated tools. The other tool at this link does this for one form, so it would not be too hard to accomplish.
 
Just a matter of time...
 
 

 ‭(Hidden)‬ Admin Links