Andrej Tozon's blog

In the Attic

NAVIGATION - SEARCH

"Call me 2.0... Silverlight 2.0"

Right... no more "Mister 1.1", no more Alpha - Silverlight 2.0 Beta is expected in Q1 2008 (@Mix?), bringing a rich set of controls (including DataGrid!), higher level of WPF UI framework, more connectivity options and richer BCL support. This Beta is expected to include a Go-Live license.

Read the full announcement on ScottGu's blog.

While on a subject, Silverlight 1.1 Tools Alpha for Visual Studio 2008 [RTM] were released a couple of days ago.

Visual Studio 2008 and Business Intelligence Projects

If you're tempted to uninstall Visual Studio 2005 after installing Visual Studio 2008 (I've done that immediately), a word of caution... There is currently no support for SQL Server 2005 BI projects in Visual Studio 2008. This means that with uninstalling VS2005 you'll lose the ability to, for example, edit Reporting Services 2005 Reports. Support for RS Reports in VS2008 are planned with the SQL Server 2008 release (due next year), but currently there's no plan to support RS 2005 Reports, only 2008.

So... to continue working with SQL Server 2005 projects, you'll have to have Visual Studio 2005 installed, but... not necessarily the whole thing. If you already uninstalled VS2005, but need it just for SQL2005 BI projects, you can now install the VS2005 shell only. Bring out your SQL2005 installation, look for the file vs_install.msi and run it. After a minute or two of silence, the installer should report that installation was successful. SQL Server Business Intelligence Development Studio, together with VS BI templates, is now back [Without all the clutter that "regular" VS2005 installation brings along].

I can't figure out why Microsoft didn't include SQL2005 BI Projects support in VS2008. I mean - with VS2008 you get all these new and improved designers for wide range of technologies, but for BI projects you'll still have to use the old VS2005 shell. I Hope that changes soon.

How many...

... of those "Visual Studio 2008 has RTM'd" posts have you read today? ;)image

Yes, it's been a busy day... Installed VS2008 this morning, uninstalled VS2005, and life is good. But are we done? Not quite; apparently we'll have to wait a couple of weeks for second-wave bits to hit our disks -  Silverlight tools for RTM, Web Deployment Project Add-in, perhaps Expression Blend 2, ... One of those is of course also the BCL source code for the debugger - I've already configured debugger settings to download and cache the library symbols and this is now the piece that's missing.

Otherwise, the installation went smooth, tested it on Windows XP and Windows Vista. System reboot wasn't required during until the end of the installation.

I couldn't spot much Beta 2 => RTM changes, except perhaps a bit more polished WPF designer, which now includes a property search box for quicker access to properties. Handy, but I kinda preferred my properties being sorted alphabetically instead of categorized. Couldn't find any setting to change that, guess I'll have to get used to it.

More VS2008 posts coming soon...

Windows Live Messenger IM Control

See the icon next to my name on the top-right of my blog page?

WLM presence icon

Green means I'm online, reachable by Windows Live Messenger. Click on the icon and WLM web control will fire up in your browser, ready to use and contact me. Nice and easy, no local WLM installation required. I'll try this presence icon thingy out and leave it right there for some time and see how that turns out. If you want to use it for your site, head this way.

There's also the Windows Live Messenger Presence API, which can be queried programmatically to return user's status. Huh!

More info here.

It's a-Live

This post was written with final version of Windows Live Writer (version 12.0.1366.1026), which was released today, along with other Live products, combined in a single installer:

liveinstaller

[This screenshot was taken on my beta/test laptop, which is... slooow - note the text in yellow. Nice]

I'm happy to announce that my MessengerQuote WLW Plugin continues to work with the release version too.

Get your Live here.

WPF/WinForms Binding Pt.2: Value converters

In previous WPF vs Windows Forms binding post, we left off with pretty useless text binding example - we made the form's title reflect whatever user writes in the textbox:

<Window x:Class="BindingSample.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="{Binding ElementName=textBox1, Path=Text}" Height="300" 
Width="300" Loaded="Window_Loaded"> ...
</Window>

public Form1()
{
    InitializeComponent();
    DataBindings.Add("Text", textBox1, "Text");
}

We'll extend this example to make it more flexible about outputting text. How about specifying a text template like "This form now belongs to {0}", where {0} would be replaced with whatever user writes in her textbox? We'll do that with the help of value converters.

To create a value converter in Windows Presentation Foundation, all you have to do is implement the IValueConverter interface:

[ValueConversion(typeof(string), typeof(string))]

public
class TextFormatter:
IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (targetType != typeof(string)) { throw new ArgumentException("Target type must be string", "parameter"); } return string.Format(parameter.ToString(), value.ToString()); } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } }

The Convert method takes a couple of parameters: value is the actual value, being passed in by binding, targetType is the type we're binding to, parameter in our case will serve for passing in the text template. We'll ignore culture as we don't need to support different locales at this time. Since we're not supporting converting the text back to initial value, we'll leave ConvertBack method unimplemented.

Next, we'll include our value converter in the binding definition.

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="BindingSample.Window1"
    Height="300" Width="300">
    <Window.Resources>
        <local:TextFormatter x:Key="TextFormatter" />
    </Window.Resources>
    <Window.Title>
        <Binding Path="Text" Converter="{StaticResource TextFormatter}" 
            ConverterParameter="This form now belongs to {0}" 
            ElementName="textBox1" Mode="Default"/>
    </Window.Title>

WPF binding with value converter 

Windows Forms, however, doesn't have something like value converters built in, but you can achieve similar result by using custom classes, which implements similar functionality:

public class SimpleTextFormatter: INotifyPropertyChanged
{
    public string parameter;
    private string value;

    public string Parameter
    {
        get { return parameter; }
        set { parameter = value; }
    }

    public string Value
    {
        get { return value; }
        set
        { 
            this.value = value; 
            OnPropertyChanged("Value"); 
        }
    }

    [Bindable(true)]
    public string FormattedText
    {
        get { return string.Format(Parameter, Value); }
    }

    public event PropertyChangedEventHandler PropertyChanged;
    protected void OnPropertyChanged(string name)
    {
        PropertyChangedEventHandler handler = PropertyChanged;
        if (handler != null)
        {
            handler(this, new PropertyChangedEventArgs(name));
        }
    }
}

Using this formatter class is again, very simple. First you have to bind form's Text property to formatter's FormattedText property, then bind the input textbox to it's Value property:

public partial class Form1 : Form
{
    private SimpleTextFormatter formatter = new SimpleTextFormatter();

    public Form1()
    {
        InitializeComponent();
       
        formatter.Parameter = "This form now belongs to {0}";
        DataBindings.Add("Text", formatter, "FormattedText");
        textBox1.DataBindings.Add("Text", formatter, "Value", true, DataSourceUpdateMode.OnPropertyChanged);
    }
        ...
}

Again, no events had to be implemented for this to work, it's just the power of data binding, even when used with Windows Forms.