Click here to Skip to main content
15,886,110 members
Articles / Desktop Programming / WPF

DataObjectBase

Rate me:
Please Sign up or sign in to vote.
4.66/5 (20 votes)
18 May 2010CPOL8 min read 37.7K   572   59  
DataObjectBase -> the new Object class for data objects!
<Windows:DataWindow x:Class="CatenaLogic.Examples.UI.Windows.RevertAndApplyWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:Windows="clr-namespace:CatenaLogic.Windows;assembly=CatenaLogic.BlogArticles" 
    xmlns:Input="clr-namespace:CatenaLogic.Examples.UI.Input" 
    Title="Revert and apply">
    
    <!-- Content -->
    <Grid DataContext="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}, Path=RevertAndApplyObject}" >
        <!-- Row definitions -->
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <!-- Column definitions -->
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <!-- First name, notice that for the "old" style bindings to work, we have to set Mode to TwoWay -->
        <Label Grid.Row="0" Grid.Column="0" Content="First name:" />
        <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding FirstName, Mode=TwoWay}" />

        <!-- Last name, notice that for the "old" style bindings to work, we have to set Mode to TwoWay -->
        <Label Grid.Row="1" Grid.Column="0" Content="Last name:" />
        <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding LastName, Mode=TwoWay}" />

        <!-- Buttons -->
        <WrapPanel Grid.Row="2" Grid.ColumnSpan="2" Style="{StaticResource RightAlignedButtonsWrapPanelStyle}">
            <!-- Create state button -->
            <Button Command="Input:RevertAndApplyCommands.CreateState" Style="{StaticResource RightAlignedFixedSizeButtonStyle}" />
            
            <!-- Revert button -->
            <Button Command="Input:RevertAndApplyCommands.Revert" Style="{StaticResource RightAlignedFixedSizeButtonStyle}" />

            <!-- Apply button -->
            <Button Command="Input:RevertAndApplyCommands.Apply" Style="{StaticResource RightAlignedFixedSizeButtonStyle}" />
        </WrapPanel>
    </Grid>
</Windows:DataWindow>

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
Netherlands Netherlands
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions