Click here to Skip to main content
15,880,364 members
Articles / Desktop Programming / WPF

Commands in MVVM

Rate me:
Please Sign up or sign in to vote.
4.97/5 (107 votes)
3 Dec 2012CPOL15 min read 509.5K   16.9K   279  
A consistent approach to Commands, Asynchronous Commands, and Events-to-Commands for WPF, Silverlight, and WP7.
<UserControl x:Class="ControlsSample.Samples.CrossButton"
             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" 
             xmlns:apexControls="clr-namespace:Apex.Controls;assembly=Apex"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <apexControls:PaddedGrid 
            Padding="6"
            Rows="Auto,Auto,Auto,Auto" Columns="5*,*">
            
            <TextBlock Grid.Row="0" Grid.Column="0" TextWrapping="Wrap" 
                       Text="The cross button is a small and simple button with a cross, useful in certain circumstances." />
            <apexControls:CrossButton Grid.Row="0" Grid.Column="1" Width="12" Height="12" />

            <TextBlock Grid.Row="1" Grid.Column="0" TextWrapping="Wrap" 
                       Text="Paths are used rather than bitmaps so it can be scaled to any size." />
            <apexControls:CrossButton Grid.Row="1" Grid.Column="1" Width="20" Height="20" />
            
        </apexControls:PaddedGrid>

    </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)


Written By
Software Developer
United Kingdom United Kingdom
Follow my blog at www.dwmkerr.com and find out about my charity at www.childrenshomesnepal.org.

Comments and Discussions