Jan 27 2011

How do you create Winform user control that supports multiple items like a listbox.

Hello,

I think I understand the basics of create winforms user control. I can do Add New and select user control and that will give me a design surface and designer file and code-behind file etc. And then I could change it to inherit from something other than UserControl (like listbox or text box).

The thing that is different for me this time is the user control needs to be a list control (like a list box) that can be data-bound and with two data-bindable controls in it (two combo boxes).

I am not sure where to start? Can anybody reference a document or some obvious bit in the tooling that I am missing that will make it quick and easy? Any approaches I can take like extending an existing control. Any gotchas I need to be aware of?

Thanks.

Seth

Jan 24 2011

Strange Character in appended text file.

I combine SQL scripts into a master sql script using a batch file like this. 

type ..\"Create Scripts"\Functions\afn_CommaSeparatedListToSingleColumnTable.sql        >> 40Programmability.sql

I added a couple of scripts to the output and the result file had these strange characters in it.



I fixed it by changing the encoding of the source files from UTF-8 to ANSI.  The UTF-8 encoding was a side effect of using visual studio to create the scripts.

Seth

Jan 20 2011

Looking for a vertical software vendor? Here is a quiz to separate the first-class from the fly-by-night vendors.

If your company is looking for a big-ticket software vendor and you want to take some early steps to find the right vendor, here is a brief quiz you could give to your candidates.

These are mostly adapted from THE JOEL TEST but I have added some things that are relevant since The Joel Test is pretty out of date.

When interviewing the vendors, set it up so that they would only have an hour or so to answer and return the test (so they can’t fake or fudge the answers.)

I would not expect perfection but on the whole most software shops (by that I mean a company whose primary line of business is selling packaged software) should be doing a lot of what is suggested by the questions.   This “test” would do a good job of separating the first class operations from the fly by night ones.  Even the first class ones that are not doing all of what is here will have strong answers and justifications.  The only way a fly by night one could pass this test is by lying through there teeth.

Speaking of lying through their teeth.  Before making a final decision maybe you should ask to SEE the operation.  Have them show you their environment and step you through the use of their ticket system, or release process, or bug-tracking software.

An irony of the economics of vertical market software is that it is traditionally a LOT more expensive but is actually LESS likely to have quality built-in.   Inexpensive single-purpose software vendors can’t afford to deliver crappy software because the support costs can easily overwhelm the revenue stream.  But vendors that charge $100,000 to &1,000,000 per installation can throw money and people at their problems (and very often bill the costs to their customers.)  I am not saying that all really expensive software is crappy.  But the potential is there so you must tread carefully.

Enjoy.

Here is the quiz.

ABOUT VERSION CONTROL

  • Do you use Source/Version Control?
  • Which Version Control system do you use? 
  • Can your developers that are working  remotely (for example, doing customer customizations) do commits and updates to your version control system (as long as there is a internet connection)?

SOFTWARE BUILDS

  • Can you make a releasable build in one step?
  • Do you make daily builds when you are product is in active development?
  • Do you use a continuous integration system?
  • What do you use for continuous integration?

BUG MANAGEMENT

  • Do you use bug tracking software?  Please describe briefly.
  • What bug tracking software do you use?
  • Do you fix bugs before writing new code? (When working against a schedule do you fix bugs before starting new features?)

METHODOLOGY

  • Do you follow a software development methodology? 
  • What is the name of the methodology you follow?
  • Is it an agile or waterfall methodology?
  • In what ways do you NOT follow the recommendations of your proscribed methodology? 
  • What role do developers play in driving your release schedule (as opposed to managers)?
  • Describe your methodology in two paragraphs or less.

PROGRAMMERS

  • Describe the method you use for hiring developers.  What steps do you try to complete?
  • Describe the working condition of your developers. 
  • How often are developer computers replaced in your company?
  • What do your developers do for professional development?

QUALITY ASSURANCE

  • Do you have in-house testers that are not developers?
  • Can developers close their own tickets in your bug tracking software?
  • Do you do usability testing as part of your UI design process?  Please describe briefly.
  • Do you have in house designers for the UI of your software?

UNIT TESTING

  • Do you use Unit Testing in the development process at your company?
  • Would you say that you use Unit Testing as part of the design process or just to be sure that changes don’t break the build.
  • What is the code coverage of your unit test suites?
Jan 17 2011

Things to remember about WPF and especially XAML #1

1.  In order to compile, XAML code must be mapped to .NET Namespaces.  Normally, when writing XAML you define XML namespaces to accomplish this.

The XML namespace that maps to various .NET controls is xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/[presentation

To see the exact many to one mappings refer to page 23 of Windows Presentation Foundation Unleashed (WPFU).

A secondary namespace that is frequently mapped with a prefix (usually x) and that maps XAML language namespace to the System.Windows.Markup .NET namespace is xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”

2.  Some properties of a XAML object can be set using both Property Attribute syntax and Property Element syntax

The following two code XAML code snippets are equivalent.  

Property Attribute Syntax
<Button Content="OK" />

Property Element Syntax
<Button>
    <Button.Content>
        OK
    </Button.Content>
</Button>

Complex types will often require the use of the Property Element syntax

3.  For all of this to work, WPF defines Type Converters that can convert simple strings into .NET complex types.

For example, Type Converters convert the White string in the following XAML
<Button>
    <Button.Background>
        White
    </Button.Background>
</Button>
into the System.Windows.Media.SolidColorBrush type (specifically the static field of System.Windows.Media.Brushes.White)

4.  Type converters inherit from the System.ComponentModel.TypeConverters class.

Many type converters are available for common .NET classes such as Brush, Color, FontWeight, Point, and so on.   You can also write custom Type converters for your own custom types.

5.  Like, Type Converters, Markup Extensions exist to extend the expressability of XAML and WPF ships with multiple Markup Extensions built in. 

The MarkupExtension abstract class exists in the .  System.Windows.Markup namespace.  

For a list of MarkupExtension classes see the inside front cover of WPFU

Markup Extensions have a more explicit and consistent syntax and are the preferred way of extending XAML. 

Markup Extensions are used in XAML attributes (or elements) by referencing the values in curly braces ({}) as shown in the following XAML
<Button Background=”{x:Null}” />

In this example you cannot set a Button background to Null because this is not supported by the Type Converter.  But by using the NullExtension Markup extension you can.  Notice that in the XAML you truncate the Extension part of the Markup extension class.




Jan 13 2011

How come the .NET framework 3.5 offline installer is 200 MBs larger than the .NET 4 offline installer?

I have code/support an application built on .NET framework that has always run on .NET 2. This year we are upgrading the application to use .NET 3.5 (or 4?).

In preparing for this change we noticed that that Offline Installer (required for our customer base) for .NET 3.5 is 200+ MBs bigger than the .NET 4 offline installer.

Here are my questions.

Why is the dotnet 3.5 installer so much bigger than the 4 offline installer?

Can we TARGET .NET 3.5 but distribute .NET 4. In other words, is .NET 4 backwards compatible? Assuming that .NET 4 was the only installed .NET could application still target earlier frameworks?

IF our application is compiled for x86 CPU (rather than Any CPU) do you still have to distribute the x64/x86 Client Profile or can we just distribute the x86 Client Profile? In other words, can we distribute the x86 Client Profile even though it will be installed on x64 machines if our app is compiled for x86 target CPU? Any risks or gotchas for doing this?

The issue is that if we upgrade our app to target .NET 4 there are a lot of application servers that we also have to upgrade which effects a number of other applications. Any thoughts?

Seth

Jan 13 2011

How come the .NET framework 3.5 offline installer is 200 MBs larger than the .NET 4 offline installer?

Hello,

I have code/support an application built on .NET framework that has always run on .NET 2. This year we are upgrading the application to use .NET 3.5 (or 4?).

In preparing for this change we noticed that that Offline Installer (required for our customer base) for .NET 3.5 is 200+ MBs bigger than the .NET 4 offline installer.

Here are my questions.

Why is the dotnet 3.5 installer so much bigger than the 4 offline installer?

Can we TARGET .NET 3.5 but distribute .NET 4. In other words, is .NET 4 backwards compatible? Assuming that .NET 4 was the only installed .NET could application still target earlier frameworks?

IF our application is compiled for x86 CPU (rather than Any CPU) do you still have to distribute the x64/x86 Client Profile or can we just distribute the x86 Client Profile? In other words, can we distribute the x86 Client Profile even though it will be installed on x64 machines if our app is compiled for x86 target CPU? Any risks or gotchas for doing this?

The issue is that if we upgrade our app to target .NET 4 there are a lot of application servers that we also have to upgrade which effects a number of other applications. Any thoughts?

Seth

Jan 07 2011

Learning WPF–First Lesson

I completed the tutorial at http://msdn.microsoft.com/en-us/library/ms752299.aspx.  It was very basic and therefore pretty straight forward but here are the things I wanted to make a special note of. 

  • XAML was edited to turn the MainWindow from Window base class to NavigationWindow.  The NavigationWindow has built in mechanisms for navigating in your application like a web-page.
    • After doing that also handed-edited the code-behind to inherit from NavigationWindow
      public partial class MainWindow : NavigationWindow
  • Screen layout is handled by special UI elements called Panels.  More on panels are at Panels Overview.  More on laying out controls at Layout System.  Here are links to the panel controls…
  • In this tutorial layout was handled by the Grid control.  Grid elements are created automatically in a new XAML page.  You can put nested Grid.ColumnDefinitions and Grid.RowDefinitions like this.
  • <Grid.ColumnDefinitions>
        <ColumnDefinition />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition />
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    • That creates a grid construct like an HTML table into which other controls can be placed. You then can state the location of the control by setting the Grid.Row and Grid.Column attribute for the control as follows.
    •  <ListBox Name="peopleListBox" Grid.Column="0" Grid.Row="1" /> 
  • To create a global control styling mechanism you can edit the App.xaml page and then create named styling nodes in the xaml that can be referenced anywhere in you application.  Like CSS, this will allow you to make a change in one place that effects the look and feel everywhere.
  • <!-- Label style -->
    <Style x:Key="labelStyle" TargetType="{x:Type Label}">
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="Margin" Value="0,0,0,5" />
    </Style>
    • To apply the style in the XAML for the label control you do something like this…

      <Label Style="{StaticResource listHeaderTextStyle}">Names</Label>
  • Data Binding was the most confusing thing.  I need to study that more.