This project is read-only.

[Version 2.0] Using DrawingImage from ResourceDictionary as LayoutItem Icon with MVVM

May 26, 2012 at 10:08 AM

I'm using the MVVM sample as base for my application.

Now I'm wondering how I can bind a DarwingImage from an ResourceDictionary as IconSource.
LayoutItem.IconSource accepts an Uri only, but I can not define a ResDict-Key in the Uri!

I'm also wondering how I can bind the IsModified and IsReadOnly properties from my model to the document header.


Jun 3, 2012 at 11:22 AM

I made a quick workaround for these issues by creating a quick DocumentHeaderTemplate:

        <DataTemplate DataType="{x:Type avalonDock:LayoutDocument}">
            <Image DockPanel.Dock="Left" Margin="3,0,0,0" VerticalAlignment="Center" Width="16" Height="16"
                   Source="{Binding Path=Content.DocumentIcon}"
                   Visibility="{Binding Path=Content.DocumentIcon, Converter={x:Static xdCore:ValueConverters.ObjectNotNullVisibity}}"/>
            <TextBlock DockPanel.Dock="Right" Text="l" Margin="5,0,0,0"
                       Visibility="{Binding Path=Content.IsDocumentLocked, Converter={StaticResource BoolToVisibilityConverter}}"/>
            <Ellipse DockPanel.Dock="Right" Margin="3,0,0,0"
                     Width="6" Height="6" VerticalAlignment="Center"
                     Stroke="Black" Fill="Red"
                     Visibility="{Binding Path=Content.IsDocumentModified, Converter={StaticResource BoolToVisibilityConverter}}"/>

            <TextBlock Text="{Binding Path=Title}" Margin="3,0,0,0" VerticalAlignment="Center"/>
Jun 4, 2012 at 3:05 PM

Thank you for posting the workaround,