Archive for June, 2011

A quick look at FluidMoveBehaviour

With Expression Blend ships a couple of assemblies that are used to implement various features on top of WPF and Silverlight. One such feature is the FluidMoveBehaviour that can be used to implement fancy stuff like this. The sample contained quite a lot of stuff and in order to see clearly what was going on, I stripped away all but the core parts. This is my version. In order to compile it references must be added to System.Windows.Interactivity and Microsoft.Expression.Interactions.


<Window x:Class="FluidMoveTest.MainWindow"





       Title="MainWindow" Height="350" Width="525">



            <ColumnDefinition Width="Auto"/>

            <ColumnDefinition Width="*"/>



        <!– Master –>

        <ListView ItemsSource="{Binding MyItems}" Name="mylistBox">




                        <Image Source="{Binding Image}" Width="100">


                                <ei:FluidMoveSetTagBehavior Tag="DataContext"/>








        <!– Detail –>

        <StackPanel DataContext="{Binding SelectedItem, ElementName=mylistBox}" Grid.Column="1">

            <Image Source="{Binding Image}">


                    <ei:FluidMoveBehavior InitialTag="DataContext" Duration="0:0:0.5" FloatAbove="True">


                            <CubicEase EasingMode="EaseIn"/>



                            <CubicEase EasingMode="EaseIn"/>










public partial class MainWindow : Window


    public class MyItemType


        public System.Windows.Media.ImageSource Image { get; set; }



    public MainWindow()



        this.DataContext = this;

        MyItems = new ObservableCollection<MyItemType>();

        MyItems.Add(new MyItemType { Image = new BitmapImage(new Uri("pack://application:,,,/FluidMoveTest;component/Resources/Hydrangeas.jpg")) });

        MyItems.Add(new MyItemType { Image = new BitmapImage(new Uri("pack://application:,,,/FluidMoveTest;component/Resources/Koala.jpg")) });

        MyItems.Add(new MyItemType { Image = new BitmapImage(new Uri("pack://application:,,,/FluidMoveTest;component/Resources/Lighthouse.jpg")) });



    public ObservableCollection<MyItemType> MyItems { get; set; }



Final application:



Categories: Uncategorized

Powershell: Multiple returns

I stumbled upon a unexpected behavior in Powershell the other day. A colleague of mine hade a code snippet similar to the following lines:

function create-directory($name)
    md $name
    return (test-path $name)

$result = create-directory "c:\temp\temp2"

I expected $result to contain true but… no! Instead it was an array with two elements; one of type DirectoryInfo and one boolean. It turns out that Powershell allows multiple returns. This means that we can write functions like:

function multiple-returns

Such a function will return an array of three string elements; John, Robert and Richard(!).

Categories: Uncategorized