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 7790261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:31:51+00:00 2026-06-01T21:31:51+00:00

I am using MVVM light in conjunction with EF4 and SQL CE 4, but

  • 0

I am using MVVM light in conjunction with EF4 and SQL CE 4, but I am having issues with my observable collection. My application doesn’t neccessarily need to use the mvvm pattern, but since I need the benefits of an observablecollection I have decided to learn how to integrate it. I can successfully link my database of property entitites to my listbox and display them, I can also link some properties of these entities to textboxes, but where I am stuck is when I try to update these properties by typing in the textbox. Here is my xaml code for a textbox and the listbox:

 <TextBox Text="{Binding SaleTitle, ValidatesOnDataErrors=true, Mode=TwoWay}"
  <ListBox Height="424" 
        Margin="24,80,0,0"             
        x:Name="listBoxProperties"
        VerticalAlignment="Top" 
        ItemTemplate="{StaticResource propertySummaryTemplate}"
        IsSynchronizedWithCurrentItem="True"  
        Width="216" BorderThickness="0" Background="{x:Null}"
        FontFamily="Segoe UI" 
        ItemsSource="{Binding PropertyList}"
        SelectedItem="{Binding CurrentProperty, Mode=TwoWay}"
        ScrollViewer.HorizontalScrollBarVisibility="Disabled"
        UseLayoutRounding="True" 
        HorizontalAlignment="Left" 
        ScrollViewer.VerticalScrollBarVisibility="Disabled" >          
    </ListBox>

Here is the code of part of my MainViewModel:

   private string _SaleTitle;
    public string SaleTitle
    {
        get
        {
            if (CurrentProperty != null)
                return CurrentProperty.SaleTitle;
            else
                return "";
        }
        set
        {
            _SaleTitle = value;
            RaisePropertyChanged("SaleTitle");
        }
    }



              private RelayCommand loadCommand;
    public ICommand LoadCommand
    {
        get
        {
            if (loadCommand == null)
                loadCommand = new RelayCommand(() => Load());
            return loadCommand;
        }
    }
    private void Load()
    {
        PropertyList = new ObservableCollection<Property>((from property in entities.Properties.Include("Images")
                                                          select property));
        propertyView = CollectionViewSource.GetDefaultView(PropertyList);
        if (propertyView != null)
            propertyView.CurrentChanged += new System.EventHandler(propertyView_CurrentChanged);
        RaisePropertyChanged("CurrentContact");
        RaisePropertyChanged("SaleTitle");
        RaisePropertyChanged("Address");
        RaisePropertyChanged("AuctioneerName");
        RaisePropertyChanged("AgentName");
        RaisePropertyChanged("Price");
        RaisePropertyChanged("NextBid");
        RaisePropertyChanged("Status");
    }


        void propertyView_CurrentChanged(object sender, System.EventArgs e)
    {
        RaisePropertyChanged("CurrentContact");
        RaisePropertyChanged("SaleTitle");
        RaisePropertyChanged("Address");
        RaisePropertyChanged("AuctioneerName");
        RaisePropertyChanged("AgentName");
        RaisePropertyChanged("Price");
        RaisePropertyChanged("NextBid");
        RaisePropertyChanged("Status");
    }

    private Property _CurrentProperty;
    public Property CurrentProperty
    {
        get
        {
            if (propertyView != null)
                return propertyView.CurrentItem as Property;
            return null;
        }

        set
        {
            _CurrentProperty = value;
            RaisePropertyChanged("CurrentProperty");
        }
    }


     public ObservableCollection<Property> PropertyList
    {
        get
        {
            return propertyList;
        }

        set
        {
            if (propertyList == value)
            {
                return;
            }

            var oldValue = propertyList;
            propertyList = value;

            // Update bindings, no broadcast
            RaisePropertyChanged(PropertiesPropertyName);
        }
    }

    public MainViewModel()
    {
        if (IsInDesignMode)
        {
            // Code runs in Blend --> create design time data.
        }
        else
        {
            // Code runs "for real"
            entities = new Model1Container1();
        }
    }

    ////public override void Cleanup()
    ////{
    ////    // Clean up if needed

    ////    base.Cleanup();
    ////}
}

}

The listbox is populated successfully with the content from current selected item, but when I type in it and click out of it or do anything to lose focus it simply goes back to what was there before.

  • 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-06-01T21:31:52+00:00Added an answer on June 1, 2026 at 9:31 pm

    Take a look at your SaleTitle property definition. It Reads value from CurrentProperty.Saletitle but sets value to local field which is not used anythere.

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

Sidebar

Related Questions

I'm using mvvm light to build a Silverlight application. Is there a code snippet
I'm using MVVM Light to build a WP7 (Windows Phone 7) application. I wish
I am using MVVM Light toolkit in my WPF application. I would like to
Trying to solve a very simple problem using mvvm-light, but after days of sifting
I'm working on an WPF application using the mvvm-light framework. I'm new to both
Hi I have a silverlight MVVM application using MVVM light. When I open the
I have successfully used a few custom commands using MVVM-Light, but I want my
I am using the MVVM Light framework as well as Unity for DI. I
In my WPF application using MVVM I noticed that in some cases the CanExecute
I'm using MVVM (MVVM Light Toolkit) and have a property on the view model

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.