Pages

Friday 25 May 2012

Editing XAML in Visual Studio

For no apparent reason VS 2010 decided to start crashing when editing XAML files. So I changed the default editor used to "Source Code (Text) Editor" which gives me syntax colouring and Intellisense but without the (crashing) Design view.
In the Solution Explorer Right-click on any XAML file and choose "Open With...".
To use the Design mode simply select the XAML file and click the "View Designer" icon in the Solution Explorer toolbar.



WPF Property Value Precedence and Style Setter

My DataTrigger / Setter was not changing the StrokeThickness property because it was exclicitly set in the Rectange tag. Property Value Precedence meant that the Setter was being overriden by the explicit property value. Moving the StrokeThickness default value into its own Setter fixed my problem.

<Rectangle
            Stroke="Black">
   <Rectangle.Style>
      <Style TargetType="{x:Type Rectangle}">
         <Setter Property="StrokeThickness"
                  Value="1" />
         <Style.Triggers>
            <DataTrigger Binding="{Binding Path=Selected}"
                           Value="True">
               <Setter Property="StrokeThickness"
                        Value="2" />
            </DataTrigger>
         </Style.Triggers>
      </Style>
   </Rectangle.Style>
</Rectangle>

Thursday 3 May 2012

SQL Column Names

I wanted to ensure that all my DB columns had been defined consistently.

Ray gave me this simple query to run on INFORMATION_SCHEMA.COLUMNS:

SELECT
   TABLE_NAME,
   COLUMN_NAME,
   DATA_TYPE,
   CHARACTER_MAXIMUM_LENGTH,
   NUMERIC_PRECISION,
   NUMERIC_SCALE,
   CHARACTER_SET_NAME
FROM
   INFORMATION_SCHEMA.COLUMNS
ORDER BY
   COLUMN_NAME