Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7652555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:48:03+00:00 2026-05-31T11:48:03+00:00

I am new to Silverlight and have been working with Simple MVVM to create

  • 0

I am new to Silverlight and have been working with Simple MVVM to create a learning app. The Simple MVVM author provides several good examples of list/detail data binding but I’m looking an example of a screen to register a user. Since this is an internal app I can pass in the Windows ID from the hosting website and check it against the user database. If the user ID does not exist I would like to display a registration where the user can enter their first/last name and click a “register” button to save a new user record. Seems like a simple pattern but I haven’t been able to figure it out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:48:05+00:00Added an answer on May 31, 2026 at 11:48 am

    Well I managed to combine a few different examples and come up with an example that works. This is part of a learning application that I am creating. It allows users (in my IT department) to suggest and vote for lunch destinations. For this app, the diner is the user. The code below will display a screen with the user’s windows ID (read only) and inputs for first/last name in addition to a “register” button.

    XAML (registerdinerview.xaml):

    <navigation:Page x:Class="LTDestination.Views.RegisterDinerView" 
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                mc:Ignorable="d"
                xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
                xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
                d:DesignWidth="640"
                d:DesignHeight="480"
                Title="RegisterDinerView Page"
                DataContext="{Binding Source={StaticResource Locator}, Path=RegisterDinerViewModel}"
              >
    <navigation:Page.Resources>
        <Style TargetType="Button">
            <Style.Setters>
                <Setter Property="Height" Value="23"/>
                <Setter Property="Width" Value="60"/>
                <Setter Property="Margin" Value="5,0,0,0"/>
            </Style.Setters>
        </Style>
    </navigation:Page.Resources>
    <StackPanel x:Name="LayoutRoot">
        <StackPanel x:Name="ContentStackPanel">
            <TextBlock x:Name="HeaderText" Style="{StaticResource HeaderTextStyle}" Text="New User Registration"/>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <sdk:Label Content="User Id:" Grid.Row="0" />
                <TextBlock Grid.Row="0" Grid.Column="1" Height="30" Text="{Binding Path=Model.UserId}" />
                <sdk:Label Content="First Name:" Grid.Row="1" />
                <TextBox Grid.Row="1" Grid.Column="1" Height="30" Text="{Binding Path=Model.FirstName, Mode=TwoWay}" />
                <sdk:Label Content="Last Name:" Grid.Row="2" />
                <TextBox Grid.Row="2" Grid.Column="1" Height="30" Text="{Binding Path=Model.LastName, Mode=TwoWay}" />
                <Button x:Name="RegisterButton" Content="Register" Click="registerButton_Click"
                             Grid.Row="3" Grid.Column="1" Height="23" Width="75" HorizontalAlignment="Left" Margin="5,0,0,0"/>
            </Grid>
        </StackPanel>
    </StackPanel>
    

    View Code behind (registerdinerview.xaml.cs):

    namespace LTDestination.Views
    {
        public partial class RegisterDinerView : Page
        {
    
            RegisterDinerViewModel _ViewModel;
    
            public RegisterDinerView()
            {
                InitializeComponent();
                _ViewModel = (RegisterDinerViewModel)DataContext;
                _ViewModel.NewDiner();
            }
    
            private void registerButton_Click(object sender, RoutedEventArgs e)
            {
                _ViewModel.SaveChanges();
            }
    
            // Executes when the user navigates to this page.
            protected override void OnNavigatedTo(NavigationEventArgs e)
            {
            }
    
        }
    }
    

    ViewModel:

    using System;
    

    using System.Collections.Generic;

    // Toolkit namespace
    using LTDestination.Services;
    using LTDestination.Web;
    using SimpleMvvmToolkit;

    namespace LTDestination.ViewModels
    {
    ///
    /// This class extends ViewModelDetailBase which implements IEditableDataObject.
    ///
    /// Specify type being edited DetailType as the second type argument
    /// and as a parameter to the seccond ctor.
    ///
    ///
    /// Use the mvvmprop snippet to add bindable properties to this ViewModel.
    ///
    ///
    public class RegisterDinerViewModel : ViewModelDetailBase
    {
    #region Initialization and Cleanup

        private IDinerServiceAgent serviceAgent;
    
        public RegisterDinerViewModel()
        {
        }
    
        public RegisterDinerViewModel(IDinerServiceAgent serviceAgent)
        {
            this.serviceAgent = serviceAgent;
        }
    
        #endregion
    
        #region Notifications
    
        public event EventHandler<NotificationEventArgs<Exception>> ErrorNotice;
    
        #endregion
    
        #region Properties
    
        private bool _IsBusy;
        public bool IsBusy
        {
            get { return _IsBusy; }
            set
            {
                _IsBusy = value;
                NotifyPropertyChanged(m => m.IsBusy);
            }
        }
    
        #endregion
    
        #region Methods
    
        public void NewDiner()
        {
            serviceAgent.GetDiners(DinersLoaded);
        }
    
        public void SaveChanges()
        {
            serviceAgent.AddDiner(base.Model);
            serviceAgent.SaveChanges(DinerSaved);
            IsBusy = true;
        }
    
        #endregion
    
        #region Completion Callbacks
    
        private void DinersLoaded(List<Diner> entities, Exception error)
        {
            // If no error is returned, set the model to entities
            if (error == null)
            {
                base.Model = new Diner { UserId = App.UserId, Active = true };
            }
            // Otherwise notify view that there's an error
            else
            {
                NotifyError("Unable to retrieve items", error);
            }
    
            // We're done
            IsBusy = false;
        }
    
        private void DinerSaved(Exception error)
        {
            if (error != null)
            {
                NotifyError("Unable to save diner", error);
            }
            else
            {
                MessageBus.Default.Notify(MessageTokens.Navigation, this, new NotificationEventArgs(PageNames.Home));
            }
        }
    
        #endregion
    
        #region Helpers
    
        // Helper method to notify View of an error
        private void NotifyError(string message, Exception error)
        {
            // Notify view of an error
            Notify(ErrorNotice, new NotificationEventArgs<Exception>(message, error));
        }
    
        #endregion
    }
    

    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Silverlight app I have an event handler that dynamically creates a new
I can create new Silverlight App with .NET RIA Services enabled. But when I
I am fairly new to Silverlight. I have an application I'm working on that
I am new to both Silverlight and WP7. I have been attempting to hotlink
I have been working with a Linq query in a Silverlight application which returns
I am new to Silverlight and have decided to give it a go. I
I have created a new silverlight business application in visual studio. It auto generates
I have been developing a managed extensibility framework application for the last several months
I have been searching on how to navigate through the pages in Silverlight 4
I'm using the Silverlight Navigation Framework and have recently been coding my appliation in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.