Click here to Skip to main content
15,896,379 members
Articles / Desktop Programming / WPF

MVVMLight Using Two Views

Rate me:
Please Sign up or sign in to vote.
4.61/5 (27 votes)
16 Oct 2012CPOL3 min read 165.4K   8.3K   62  
How to create an MVVM application using MVVM Light with multiple views in one window
<Window x:Class="MvvmLightTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Mvvm Light Example"
        Width="525"
        Height="350"
        DataContext="{Binding Main,
                              Source={StaticResource Locator}}"
        ResizeMode="NoResize"
        SizeToContent="WidthAndHeight">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="257*" />
        </Grid.RowDefinitions>
        <Button Command="{Binding ShowPopUp}" Content="Show Pop Up" />
        <Button Grid.Row="1"
                Command="{Binding IncrementValue}"
                Content="Increment value" />
        <TextBlock Grid.Row="1"
                   Grid.Column="1"
                   MinWidth="50"
                   HorizontalAlignment="Center"
                   VerticalAlignment="Center"
                   Text="{Binding ExampleValue}"
                   TextAlignment="Center" />
    </Grid>
</Window>

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
United Kingdom United Kingdom
Jack of all trades.

Comments and Discussions