Click here to Skip to main content
15,893,486 members
Articles / Desktop Programming / WPF

The Service Tree Model

Rate me:
Please Sign up or sign in to vote.
4.55/5 (11 votes)
9 Jul 2010CPOL4 min read 34.4K   192   20  
A new application architecture as an alternative to composite architectures such as Prism
<UserControl x:Class="ServiceTreeSample.Views.TabbedDocumentView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <TabControl ItemsSource="{Binding Documents}">
        <TabControl.ItemContainerStyle>
            <Style TargetType="TabItem">
                <Setter Property="IsSelected" Value="{Binding IsActive}"/>
                <Setter Property="HeaderTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Document.Title}"/>
                                <TextBlock Text="*" Margin="3,0">
                                    <TextBlock.Style>
                                        <Style TargetType="TextBlock">
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding Document.IsModified}" Value="False">
                                                    <Setter Property="Visibility" Value="Collapsed"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </TextBlock.Style>
                                </TextBlock>
                                <Button Command="{Binding CloseCommand}">
                                    <Button.Template>
                                        <ControlTemplate TargetType="Button">
                                            <Grid Margin="3,0,0,0">
                                                <Ellipse Width="12" Height="12" Fill="DarkRed"/>
                                                <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="×" Foreground="White"
                                                           Margin="0,-2,0,0"/>
                                            </Grid>
                                        </ControlTemplate>
                                    </Button.Template>
                                </Button>
                            </StackPanel>
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="Content" Value="{Binding View}"/>
            </Style>
        </TabControl.ItemContainerStyle>
        
    </TabControl>
</UserControl>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Cyest Corporation
South Africa South Africa
David is a software developer with an obsession for analysis and proper architecture.

Comments and Discussions