Data Services with Silverlight 2 – New Name, Same Book

Thursday, July 03 2008 - , - 0 comments

It’s really semantics, but the title of my book has been changed slightly to now be called “Data Services with Silverlight 2”. Titles are not super important to me, but it became clear to me as the book was flowing out in Word and OneNote that the many of the topics were tending to be focused on data services. For example: using Silverlight 2 with WCF, RSS, REST, Cross Domain issues, Sockets, LINQ to XML, and so on. Dealing with data from Silverlight is the central theme of the book. This includes data binding, getting data from services, sending it back, and massaging the data. So in the end the new title just made more sense.

I’m pretty excited about where the book is heading, its really unfolding nicely so far. I cannot wait til its out later this year!

book2

My Book Has a Life of its Own

Sunday, June 29 2008 - , , - 0 comments

I set out to write a book on data access, services, and Silverlight 2 and stick to those topics faithfully. I have a sticky note on my desk that shows the main topics and the word “thin” as a reminder to myself to stick to the point and keep the book thin  … thin as in not a brick that someone could bludgeon me with if they don’t like the book :)

Data Access with Silverlight 2

When I buy an intermediate to advanced book, I love it when the book gets to the point, shows me what I need to know and skips over the 250 pages of introductory material.  Perhaps a chapter or 2 of intro material is fine, because then I can skip over it if I need to or read it if the material is indeed new to me.

My book is not an introduction to Silverlight. It is not an all encompassing book telling the reader everything there is to know about Silverlight. Rather my book explains what is needed to build data driven applications using the most appropriate tools in Silverlight to accomplish this goal.

This does cause a bit of a dilemma because I feel that you cannot build data driven applications in Silverlight without understanding Dependency Properties and the fundamentals of Silverlight’s data binding. I cover these areas, but to stay true to my sticky note, I cover these topics with a little bit of “why” and a little bit of “how” … and I don’t take 250 pages to cover them.

The bulk of the material is starting to take shape and I just looked at my original table of contents and laughed. Its 90% different at this point :) I mentioned a few weeks ago that I use OneNote to organize my thoughts and my chapters. I would be lost right now without it. I have moved ideas, chapters, created new chapters, and sliced and diced my notes so many times that I cannot imagine how I would stay focused without it. OneNote keeps me writing instead of trying to figure out how to organize myself. it is also a great tool for figuring out what you will be writing about in the next chapter. Which at this point, i am realizing that all i can promise myself is what will be in this chapter and what will follow it in the next chapter.

I am having a good time putting the material together, and other than the DataGrid (whose beta state is not fun), the rest of the material is flowing out pretty well. I am looking forward to seeing the completed work in December later this year (which means I need the bulk of it done by September!). The funny thing is that I am working harder on this this shorter book than I did on any of my books that were twice as long!

My Fall is Taking Shaping - VSLive NY in September

Saturday, June 28 2008 - , , , , , - 0 comments

I’ll be flying to New York City in September to present 2 sessions at VSLive NY at the Marriott at Brooklyn Bridge from Sep 7-10. They’ll be some great sessions there from some great presenters. Registrations are open now.

image

Even though the conference season is on break over the summer, my summer has been a bit crazy so far with writing my upcoming book on data access, devices and Silverlight 2. I’ve got a few nice breaks with some user groups that i have done and a few more I am looking forward to. Its great to get out and share with the community. In July I will be heading to Miramar Florida and to Albany NY for some great user group meetings. Head over to my events page to see my full lineup, as it unfolds.

A colleague and friend of mine, Brian Peek, who’s fame is skyrocketing lately will be presenting 2 sessions here as well. Brian is the author of the Wiimote library that has been talked about and downloaded by many people and has even been discussed in Newsweek magazine. If you plan on attending VSLive, be sure to check out Brian’s sessions.

I’ll be presenting the following sessions at VSLive in NYC:

Building Effective Data Bound Applications with WPF and Silverlight
John Papa
Monday, September 8, 4:45 p.m.
XAML makes it easy to design robust user interfaces and it provides powerful data-binding capabilities. With WPF and Silverlight, you can perform data manipulation using code, XAML, or a combination of both. You can bind to controls, public properties, XML, or objects, making data binding quick, flexible, and easier than ever. This session will demonstrate how to use these data binding features with WPF and Silverlight applications.

ASP.NET Data Binding
John Papa
Tuesday, September 9, 9:45 a.m.
Generics can enhance the implementation of a data access model. You can bind a list of objects directly to a bindable control or you can use the ADO.NET DataSet. The new data binding and data source objects in ASP.NET are a huge step forward in reducing and simplifying UI code. This session will begin by demonstrating how to use the SqlDataSource to retrieve and modify data from an OLE DB compliant database and bind it directly to an ASP.NET web form, without writing any code. The ObjectDataSource is ideal for multi layer applications as it allows data bound web controls to bind to a data source through a middle tier class library or web service. It can also be used to assist in binding either a DataSet or a list of objects using Generics. I will demonstrate these new data source tools and walk through examples of when and where each is ideal.

Silverlight 2 Binding Modes Diagram

Monday, June 23 2008 - , , , - 2 comments

Here’s a tiny little nugget from my upcoming book. There are always concepts that are just natively drilled into me yet they don’t flow smoothly when I try to explain them. For example take the Silverlight 2 binding modes. You have OneTime, OneWay and TwoWay as options. OneWay is the default and many examples of XAML based binding I see of XAML in both Silverlight and WPF omit the Mode property entirely. But OneTime is not always the appropriate option, either. Read only data is better suited for OneWay while editable data is suited well for TwoWay. Data that should only be bound and displayed when the source is first bound is ideal for OneTime.

There are nuisances to the scenarios, too (aren’t there always?). For example, OneWay and TwoWay bindings rely on the INotifyPropertyChanged interface and its PropertyChanged event being raised. 

OK, so my point is that sometimes explaining these types of situations is more difficult than just showing them with code. I;ve always been more about show me the code and sprinkle a little bit of explanation around it. To me that is so much easier to comprehend than reading a dozens of pages without code or pictures.

image

So I came up with a simple diagram for to help myself explain the binding modes a little bit. Its not the only tool I use (I use code samples, other diagrams, and words too) but its one I start with. I figured I would share it for any who might be interested. You can also find a variation of this diagram in my upcoming book Data Access with Silverlight 2 published by O’Reilly (Dec 2008).

Tutorial: Create a Silverlight 2 User Control from a Popup Control

Thursday, June 19 2008 - , - 2 comments

I created a simple user control using the Popup control as a starting point. The end result is a nice little user control that can be used as a popup control to display a message. It has only 1 button on it (an OK button that closes the popup control). I’ll outline the basic steps of creating the User Control and how the popup control works with it. Of course, you can create a popup control without the user control, but its a much cleaner practice to create user controls.

Step 1)  Create a tester control. I called mine PopupTester.xaml. It can contain just about anything you want, in my case I put a funky looking green filled border on the control and a button, that when clicked will call the user control that we’re about to create. You can skip the code for the event handler for the button for now.

The PopupTester control is the default control that will be loaded when the Silverlight application is started. (Set this in App.xaml.cs)

Here is how the PopupTester control looks in Expression Blend. (It has no background color, which is why it appears gray.)

image

Step 2)  Create a new User Control and name it MyPopupControl.  The complete XAML for the control is shown a little further down. Remove the background, width, and height from the Layout Grid control so it only has a name property of LayoutRoot..

Step 3)  Slap a Popup control in the main layout Grid. Name the popup control popMessage.

Step 4)  Create a Grid inside of the Popup control. Create 3 rows and 3 columns in the Grid. Make the 2nd row and the 2nd column (the middle ones) have a Width = Auto. This creates a nice little grid that we can use to center the popup control contents. There are other ways to do this, but let’s swing with it.

Step 5) Add a Border to the Grid inside of the Popup control. Style the border however you wish, but make sure you give it a background color of some sort so it gets filled in. I gave mine a gradient background color from top to bottom and set the opacity to make it slightly transparent.

Step 6) Next,  add a StackPanel inside of the Border, and stick a TextBlock and a Button inside of the Stackpanel. The TextBlock contain the message and the Button will be used to close the popup control. Name the TextBlock tbPopupMessage and the Button btnClose.

The XAML should look something like this:

<UserControl x:Class="SLPopupDemo.MyPopupControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot">
        <Popup x:Name="popMessage">
            <Grid x:Name="theBack" Background="#80000000">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition Height="Auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Border BorderBrush="#7F4895DE" BorderThickness="1,1,1,1" Width="400" 
                    Height="200" Padding="10,10,10,10" CornerRadius="25,25,25,25" 
                    Grid.Column="1" Grid.Row="1">
                    <Border.Background>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="#FF000000"/>
                            <GradientStop Color="#CC4895DE" Offset="0.844"/>
                            <GradientStop Color="#FF346592" Offset="0.393"/>
                            <GradientStop Color="#FFFFFFFF" Offset="1"/>
                        </LinearGradientBrush>
                    </Border.Background>
                    <StackPanel Height="Auto" Width="Auto" Orientation="Vertical" >
                        <TextBlock  x:Name="tbPopupMessage" Height="143" Width="Auto" 
                            Text="Message Goes Here" FontFamily="Trebuchet MS" FontSize="24" 
                            HorizontalAlignment="Center" VerticalAlignment="Center" 
                            Foreground="#7FFFFFFF" TextWrapping="Wrap" TextAlignment="Center"/>
                        <Button x:Name="btnClosePopup" Height="30" Width="80" Content="Close"/>
                       </StackPanel>
                </Border>
            </Grid>
        </Popup>
    </Grid>
</UserControl>

 

Step 7) Now we need to ad some code to the MyPopupControl user control to create its event handlers. We’ll need events for the Button’s close event and to resize the control when the application resizes. So add the following constructor code to your code behind:

public MyPopupControl()
{
    // Required to initialize variables
    InitializeComponent();
    btnClosePopup.Click += new System.Windows.RoutedEventHandler(btnClosePopup_Click);
    App.Current.Host.Content.Resized += (s, e) =>
    {
        theBack.Width = App.Current.Host.Content.ActualWidth;
        theBack.Height = App.Current.Host.Content.ActualHeight;
    };
}

Using Visual Studio the event handlers are automatically created for the button. I used an anonymous delegate with lambda styling to for the resizing code just for fun. We could have simply created an event handler for it, though (like for the button). (Shawn WIldermuth inspired me to be creative with this technique after reading a post he wrote on creating a popup dialog, too. originally I had created an event handler for this, which is probably what I would od in a real application since I think its easier to debug & read.)

Step 8) Add the code to the button to close the popup control.

private void btnClosePopup_Click(object sender, System.Windows.RoutedEventArgs e)
{
    this.Close();
}

Step 9) Create a public property on the user control to get & set the Message in the control.

public string Message
{
    get { return tbPopupMessage.Text; }
    set { tbPopupMessage.Text = value; }
}

Step 10) Create a public method to open the control and one to close the control. 

public void Close()
{
    popMessage.IsOpen = false;
    this.Visibility = System.Windows.Visibility.Collapsed;
}
 
public void Show()
{
    popMessage.IsOpen = true;
    this.Visibility = System.Windows.Visibility.Visible;
    btnClosePopup.Focus();
}

The code in the Show method sets the IsOpen property of the popup control, which makes the control open up. We also toggle Visibility. The Close method does the opposite.

Step 11) Go to the XAML of the PopupTester control and add the MyPopupControl user control as the last element just before the layout Grid closes.

<SLPopupDemo:MyPopupControl x:Name="myPopup" Visibility="Collapsed"/>

Step 12) Once you add this XAML, you will have to add a reference to the namespace at the top of the user control, too, like this

xmlns:SLPopupDemo="clr-namespace:SLPopupDemo" 

Step 13) Go to the PopupTester control’s codebehind and add the following code.

public PopupTester()
{
    InitializeComponent();
    showButton.Click += new RoutedEventHandler(showButton_Click);
}
 
void showButton_Click(object sender, RoutedEventArgs e)
{
    myPopup.Show();
}

This code adds the event handler for the button that will open the MyPopupControl instance. The event handler simply calls the popup control’s Show method, that we created in the previous step.

Step 14) Now compile the app and run it. When you click on the button it the popup control will appear to be in front of the entire PopupTester control (because of its gray slightly transparent and stretched background. Like this:

image

No magic, just pretty simple code and layouts.

Here is the source code …. Enjoy!

Silverlight Presentations On the Horizon

Thursday, June 19 2008 - , , , - 2 comments

I am sitting down writing about WCF interaction with Silverlight, cross domain issues, and other fun communication stuff. As I am drumming through these examples for the book and for some articles and presentations (phew) I am running into minor issues that really cause me to think differently about how to tackle them. For example, I wanted to produce a model popup window in Silverlight. Sure, no problem, I’ll just use the … wait … there is no modal popup control. There is a popup control, but its not modal. And it lacks a bit of refinement. I see from my friend Mr Google that others have tackled this issue in various ways … such as …

- Creating an abstract class that derives from the ContentControl and implementing methods that render the popup

- Creating a popup control inline in code, and restricting keyboard and mouse movement beyond the popup control

For now, since I could not find an elegant solution that I could fall in love with, I decided to create a popup control in a user control and expose custom properties on the user control so I could tweak the popup control and simulate modality. The user control has a canvas that stretches out over the base Silverlight control with a 50% opacity. This simulates a graying out of the background when the popup control appears and prevents mouse interaction. It does not prevent tabbing back into the originating Silverlight application, but that;s next on my list.  It ain’t perfect, but it works good enough for now. I have to think that there will be an easier way to simulate modality in the future, at least by RTM.

Anyway … this and other issues like it got me to thinking that it might be a good thing to present some of these issues I am running into on my blog in narrative form like this post, in code samples, and in camtasia vdeos. I’ve got plenty to share … the only catch is finding the time between my main job, my speaking schedule, and my writing schedule and leave time for the family. The same ol’ battle :) But I think I will have some time to do some quick videos and postings on these topics so here’s my vow to share some of my Silverlight adventures, both successful and unsuccessful, in the coming weeks and months. The first will likely be on the modal popup that I described in this post. My hopes are that this sharing process will help refine some of these bumps in the road for Silverlight junkies like me.

TextBox is Not Behaving in Silverlight 2 Beta 2!

Wednesday, June 18 2008 - , , - 3 comments

I’m putting together some samples for an article for my Data Points column in MSDN Magazine on writing a line of business application with Silverlight communicating with WCF, and I ran into a few issues I did not expect. The one that really confused me causes the TextBox controls in the Silverlight application to:

    • not show the cursor in the TextBox (although I can type)
    • not show the contents being selected in the TextBox
    • breaks the TwoWay binding mode

I was living with the first 2 because I thought, eh, what the heck, its beta and I obviously hit some weird occurrence. But when the binding only worked one way from the source to the target TextBox controls, I knew I had a real problem. The TextBox controls when bound with Mode=TwoWay were not updating the source when I typed in the TextBox controls (and lost focus of course).

After a few posts in the Silverlight forums and some emails with some fellows at Microsoft, it was confirmed that there is a bug in the Silverlight 2 Beta 2 that causes the TextBox to not behave properly. The confusing aspect is trying to reproduce the problem. So I created a simple Silverlight user control, shown below:

<UserControl x:Class="TextBoxTester.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
        <TextBox x:Name="tbMsg" Text="Hello World" Height="30" Width="Auto"></TextBox>
    </Grid> 
</UserControl>

 

When this control is run from Visual Studio, there is no problem … nor is there a problem if I browse to the html page that hosts the compiled Silverlight application. WTF, says I! But if I browse to the html page that hosts the app, then REFRESH the page in the browser forcing the Silverlight control to reload the TextBox starts behaving badly. I tried this several times and it always reproduced it. However there are people I gave this same code to who saw the same behavior and others who did not. So there is obviously some other force intervening in this that I am not aware of still.

There are no error messages, no informational messages, nothing at all except a misbehaving TextBox control.

Anyway, I have been told that there is a bug regarding the TextBox control and that it will be fixed in a future release (prior to RTM of course). The causing factors are not completely known to me, but in case you run across this I figured I would shed a little light on it. The way I get around it for now is to click in the address bar of the browser, then click back on the Silverlight control. This seems to put the TextBox’s world back in order.

Template Binding with Silverlight – Resource to Resource

Sunday, June 15 2008 - , , - 1 comments

I mentioned a few weeks ago that Corrina Barber is creating some elegant skins that I will be using for my samples in my upcoming book Silverlight 2 with Data Access. Corrina has updated quite a bit with the templates due to the changes from beta 1 to beta 2, throw in some minor tweaks that I am making to them, and they are coming along quite well for the book.

One of the changes I began making is creating a way to have a base color that all the control’s skins can use. For example, Corrina has done a fantastic job making some elegant style templates for the Silverlight controls. The controls were originally written to be in the red spectrum of colors. I wanted to make them use a shade of blue as they base color. So all I had to do was go into the templates and create a single resource for the SolidBrushColor for the shade of blue I wanted and then bind each of the style templates that Corrina created to that resource. For example, in App.xaml I added this resource:

        <SolidColorBrush x:Key="BaseColorBrush" Color="#FF00135B"/>

Then I referred to this resource from the styles in app.xaml, like this:

<!--Button Style-->
<vsm:Style x:Key="ButtonStyle" TargetType="Button">
    <vsm:Setter Property="Background" Value="{StaticResource BaseColorBrush}"/>
    <vsm:Setter Property="Foreground" Value="#FFFFFFFF" />
    …

Every style in app.xaml refers to this base color at one or more locations.

image

This works out great since I want all of the styles for all of the controls to hang off this base color. And if you want to use a different shade of blue or even a different base color like green, purple, or yellow you just change the base SolidColorBrush resource. One of my favorite things about Silverlight development is that Blend and the Visual State Manager tools make it easy for a non graphically inclined developer like myself to actually create slick looking styles. Its a very cool thing!

Corrina is going to post some information on her skins and share some tips on how she created them using Blend and the new Visual State Manager tools. So definitely look out for her posts.

image

Silverlight 2 Beta 2 Rundown

Sunday, June 08 2008 - , - 4 comments

By now you know that Silverlight 2 Beta 2 was released Friday evening. There have been some great posts by several people piling up over the weekend on the changes, new features, features still missing, and much more. Here is a quick rundown of some links you should really check out if you are using Silverlight 2 Beta 2.

And me? I’ve been busy working on my Silverlight 2 book. But I promise to blog some more as I move along. :-)

What’s New in Silverlight 2 Beta 2 Tools

Friday, June 06 2008 - , - 0 comments

No, its not out yet (as far as I can tell). Mike Snow of the Visual Studio Web Tools team posted a nice list of the changes that are in the Silverlight 2 Beta 2 Tools for Visual Studio 2008 (phew, long name!). I recommend reading his entire post.

Here are some highlights I pulled out:

  • There is much new added support for debug vs release builds of XAP’s. This includes:
  • You can now add a Silverlight 2 ready WCF project from a project template
  • When converting a project from Beta 1 to Beta 2, you will be prompted for conversion confirmation
  • XAML now reports error. Woohoo!!! (yes, I am easily satiated)

A few notes about all of the beta’s that have come out lately  and are still coming (from Mike Snow’s post) …

      • Uninstalling previous versions is no longer necessary. However, if you install SP1 over Beta 2 you will need to re-install Beta 2 to update the patch. Also, our tools setup removes the Microsoft Blend March Preview. Microsoft Blend will be re-releasing around the same time as the release of our Beta 2 tools.

Silverlight 2 SDK Beta 2 Documentation

Thursday, June 05 2008 - - 1 comments

The Silverlight 2 SDK Beta 2 documentation is now available to be downloaded. It is a 50MB download of the compiled help files jam packed with good stuff :)

Here are some highlights from the beta 2 help files:

  • There is a long list of Breaking Changes. Need to review these for sure. The first one mentions that you need the latest Silverlight 2 Beta 2 Tools for Visual Studio 2008 (phew, long title) before using your projects. Yeah, pretty obvious ... but important :)
  • The new TabControl is included in the docs ... nice stuff in there.
  • There are now 8 data binding markup extensions. They added Path (which was set via the constructor in beta 1), NotifyOnValidationError, ValidatesOnExceptions.

Notice this beta 2 teaser blurb from the page:

If you have the Silverlight 2 SDK Beta 2 installed, please save the Silverlight.chm in this package to the Documentation\Help folder of your SDK install.

  Enjoy!

Silverlight 2 - Dependency Properties and DataContext

Thursday, June 05 2008 - , , - 3 comments

Today my latest article on Silverlight 2 was posted on Simple-Talk . The article explains the foundations of data binding in Silverlight 2 including the importance of Dependency Properties and  the DataContext. I intend on following this up with future articles on the topic, too.

This article contains a small excerpt from a very early chapter in my upcoming book Data Access with Silverlight 2, by O’Reilly.  I’ll be posting small nuggets on my blog and through articles along the way to give everyone an idea of what’s inside the book. The book is due out late this year, probably December 2008. I’d like to get it out earlier, but there is a lot to write about still that may change in the betas, so its a tough balance.

Data Access with Silverlight 2

Enjoy!

Full List of New Features in Silverlight 2

Thursday, June 05 2008 - , - 0 comments

There is a great list of all of the new features in Silverlight 2 beta 2 at this link. The release is supposed to be out this week, which would be today or tomorrow, one would hope.

A few highlights from that post that caught my eye:

  • The Visual State manager
  • A new Deep Zoom Composer tool is on its way
  • A new tab control
  • TextBox scrolling & wrapping
  • Support for element syntax for binding markup extension

 

With this release there will be a new SL installation, a new rev of Blend 2.5 (the June 2008 Preview), and a new rev of the Silverlight tools for Visual Studio. Jesse Liberty posted some of the effects of the changes in beta 2 including the changes to the event bubbling of controls. This is a good read as it now works more like WPF. Jesse also updated many of his tutorials other than the styles tutorial. I imagine that is because he is going to integrate the VSM and some other new features into that one, since its sooooo darn cool. If you have not checked out the new VSM, you really gotta.

The wait for the release continues …

SL

Visual State Manager in Blend 2.5

Tuesday, June 03 2008 - , , , - 1 comments

Christian Schormann posted a video that demonstrates the new Visual State Manager (aka VSM). The quick and dirty is that the VSM allows you to customize the states of a control. This means you can change the visual presentation of a control for its mouseover state, pressed state, or whatever other states the control might have. Christian’s demo shows this very well.

image

These features are available in the new Silverlight 2 beta 2 and Blend 2.5 June 2008 Preview bits that will be coming out this week.  The more I use Blend the more I see how a graphically challenged developer like me can create very rich interfaces.

This is a great video (and very short), check it out.

Silverlight 2 Beta 2 This Week!

Tuesday, June 03 2008 - , , , - 2 comments

Somasegar was on-stage today at TechEd and announced that Silverlight 2 Beta 2 is going to be released with a GoLive license this week. This also will include a Blend 2.5 June 2008 Preview and tools to VS2008. I’m looking forward to getting the bits this week and working them into my Silverlight book!

The good news (for me) is that nothing I have written about in the first few chapters of my book has changed. The better news is that there are a lot of improvements to items that I will be writing about in the book, so I get to take advantage of them and pass them along. I was going to write about how to sort and do tricks with the DataGrid using some code I wrote, but now it looks like it is baked in.

Here are some of the highlights for Silverlight Beta 2 from the session:

  • Deep Zoom:
    • improved event driven notifications
    • new XML-based file format for Deep Zoom image tiles
    • new MultiScaleTileSource
  • UI Framework
    • more WPF UI features now in Silverlight
    • enhanced
      • animation
      • error handling
      • automation and accessibility
      • keyboard input
      • performance
  • Networking Support
    • Improved Cross Domain support
    • Security enhancements
    • Upload support via WebClient
    • LINQ-to-JSON is now included (formerly a prototype)
    • ADO.NET Data Services support (aka Astoria)
    • Improved SOAP support
  • Rich Controls
    • Visual State Manager
      • New and easier templating model
    • New TabControl
    • TextBox
      • text wrapping
      • scrollbars
    • DataGrid
      • Autosize
      • Reorder
      • Sort

    6 Great Tools For Writing a Book

    Friday, May 30 2008 - , , , , - 5 comments

    Someone asked me yesterday what tools I use while writing a book. Organization is absolutely critical to me when writing. I have so many thoughts flying around that its really difficult to keep them all straight. That is why its imperative to have some tools to help organize the book writing process. The publisher provides some templates to write with in Word that are mostly helpful (and sometimes painful :) ). Here are some good tools that I am using while writing my new book Data Access with Silverlight 2 .

    1. Microsoft OneNote 2007

    imageI cannot stress enough how important this tool is to me. It helps me organize my thoughts by keeping track of code samples, ideas for demonstrations, stray notes, chapter flow, and things to come back to. I created a notebook in OneNote for my book and created sections for each chapter. Each chapter has several pages in it with ideas for the chapter. The first page contains the flow for the chapter with all of my ideas for sections in the book, as well as ideas for examples and figures.  The rest of the pages go into detail for each of the major sections. When I realized I had too much information in chapter 2, I simply dragged the content from that chapter section over to the next chapter and I was done. One Note is great for things that pop up while you are writing, but you don;t want to get caught up in a tangent. I jot these down in the One Note notebook and come back to it later. One of the best features of One Note for writing is that you can search all of the content very easily.

    2. Tech Smith's Snag-Itimage

    I am constantly needing to grab screen shots of menu's, windows and other of demonstrations for the book. This tool is easy to use and works very well. Enough said!

    3. Tangible Software Solutions' Instant VB / Instant C#

    These tools help convert code samples from VB to C# and back. It works very well and very fast! I've taken an entire project of a couple hundred C# files and converted from C# to VB and it handled it under a minute! There are some free solutions, but this one is my favorite so far.

    4. Lutz Roeder's .NET Reflector

    This tool is just plain awesome. Its been out for years and everyone knows about it. But for writing a book its great to help show the source code for .NET libraries. I found this especially useful when explaining Dependency Properties in my Silverlight book. Just jump right in, search for the class, and up pops the source code for the method or property you are looking for.

     

    5. PowerPoint

    This tool makes it easy to create simple diagrams for the book. I create the diagrams in a PowerPoint slide deck and use Snag-It to create png files from them. I tend to save each slide for the book in the deck, too. This way I can go back and edit the diagram easily if I need to.

    6. Paper and Pencil

    This is my second favorite tool (OneNote being the first). Sometimes I just need to draw something without thinking about the tool at all. Paper and pencil is second nature to most of us as we can easily jot down an idea and draw it up much faster with a pencil .... fast enough that I won't lose my thought!  My kids even laugh at me sometimes because I carry the pencil behind my ear :)

    Keeping Focused on Silverlight and Data

    Wednesday, May 28 2008 - , - 2 comments

    I'm working with the very talented Corrina Barber who has created several sets of skins for Silverlight controls. The skins are elegant, but not over the top, styles that can be applied to Silverlight controls. Corrina has been gracious enough to help customize a set of styles for the controls in my upcoming book "Data Access with Silverlight 2". They will be freely available with the downloadable code for the book and from the book's web site at www.silverlight2data.com , which I will be setting up in the near future (right now it just points to my same site at www.johnpapa.net).

    The focus of my book is on data access with Silverlight (yeah, pretty obvious from the title) ... it is not on how to make a variety of styles, storyboards and animations. But that does not mean the samples have to be ugly. In fact, there are some very good reasons to make examples that use elegant styles in the book (without giving away too