Click here to Skip to main content
12,630,913 members (34,339 online)
Click here to Skip to main content

Stats

44.1K views
802 downloads
74 bookmarked
Posted

Presentation Model (MVVM) Good Practices

, 11 May 2010 CPOL
Showing some good practices that can be applied to the Presentation Model/MVVM pattern.
App.Configuration
App.Configuration.Wpf
Interceptors
Properties
Wpf
Properties
Wpf
App.Core
Model
PresentationModel
Properties
Services
App.Data
Properties
libs
AttachedCommandBehavior.dll
Castle.Core.dll
Castle.DynamicProxy2.dll
Castle.MicroKernel.dll
Castle.Windsor.dll
PresentationModelBase
Properties
WPFUI
Properties
View
<UserControl
    x:Class="WPFUI.View.ProductEditView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Style="{StaticResource ViewStyle}"
    >
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="30"/>
            <RowDefinition Height="30"/>
            <RowDefinition Height="30"/>
            <RowDefinition Height="30"/>
            <RowDefinition Height="30"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <DockPanel
            Margin="5"
            Grid.Row="0"
            Grid.Column="0"
            >
            <TextBlock
                Width="50"
                DockPanel.Dock="Left"
                Text="Name : "
                />
            <TextBox
                Width="150"
                DockPanel.Dock="Right"
                Text="{Binding ProductName}"
                />
        </DockPanel>
        <DockPanel
            Margin="5"
            Grid.Row="1"
            Grid.Column="0"
            >
            <TextBlock                
                Width="50"
                DockPanel.Dock="Left"
                Text="Price : "
                />
            <TextBox
                Width="150"
                DockPanel.Dock="Right"
                Text="{Binding ProductPrice}"
                />
        </DockPanel>
        <DockPanel
            Margin="5"
            Grid.Row="0"
            Grid.Column="1"
            Grid.RowSpan="5">
            <TextBlock
                Width="50"
                Text="Photo : "
                DockPanel.Dock="Left"
                />
            <StackPanel
                DockPanel.Dock="Right">
                <Border
                    BorderThickness="1"
                    BorderBrush="Black">
                    <Image                        
                        Height="100"
                        Width="100"
                        Source="{Binding ProductPhotography}"
                        />
                </Border>
                <Button
                    Content="Change"
                    Command="{Binding Call}"
                    CommandParameter="ChoosePhoto"
                    />
            </StackPanel>
        </DockPanel>
        <Button 
            VerticalAlignment="Bottom"
            HorizontalAlignment="Right"
            Grid.Column="3"
            Grid.Row="6"
            Content="Save"
            Command="{Binding Call}"
            CommandParameter="SaveOrUpdate"
            />
    </Grid>
</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)

Share

About the Author

Software developer specialized in the .NET framework

You may also be interested in...

Pro
Pro
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161205.3 | Last Updated 11 May 2010
Article Copyright 2010 by Thiago de Arruda
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid