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

  • Home
  • SEARCH
  • 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 7407371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:42:28+00:00 2026-05-29T05:42:28+00:00

I have a WPF window with some textboxes, comboboxes and a grid using MVVM

  • 0

I have a WPF window with some textboxes, comboboxes and a grid using MVVM
the comboboxes and grid are bound to DataTable and DataViews, only the selectedItem values are bound to the Model

As of now, using helper methods as follows

void GetSelected()
{
  if ( SelectedDataRowView != null )
    obj.prop1 = (int)(SelectedDataRowView.Row["field1"]);
  else
    obj.prop1 = defaultValue1;
  if ( SelectedDataRow1 != null )
     obj.prop2 = (double)(SelectedDataRow["field2"]);
  if ( SelectedDataRow2!= null )
     obj.prop3 = (string)(SelectedDataRow2["field3"]);
  ...
}

/// and

void ToSelected()
{
 if ( TryFindDataRow("field1", obj.prop1, dv1, out drv1 ) 
   SelectedDataRowView = drv1;
 else
   SelectedDataRowView = null ;
  ...
}

as you can see, its pretty ugly, wondering how to clean it up !!

FYI can,t use EF & get rid of DataTable/DataView for now – the db is non sql server

  • 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-29T05:42:29+00:00Added an answer on May 29, 2026 at 5:42 am

    Maybe you can convert your DataTable / DataRows to POCO objects with proper interfaces and put them in ObservableCollection which are more MVVM friendly. You can write mappers to achieve this or use frameworks like AutoMapper. You can keep using what you do and just use a mapper layer to convert them back and forth.

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

Sidebar

Related Questions

I have a FlowDocument in a standard WPF application window where I have some
I have a window in WPF which shows some media contents. This content contains
I have a borderless and transparent window in WPF, with some fancy decoration at
I have a WPF window for editing database information, which is represented using an
In WPF I have one window opening a second window that allows some data
I have observed some unexpected or at least not-perfectly-matching-my-needs behaviour of textboxes bound to
I have a WPF Window with WindowStyle set to none. Is there some way
I have a WPF Window defined in XAML like this: <Window x:Class=com.some.company.window xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
I have the following grid in my WPF Window (yes the class Window); <Grid
I am building a WPF application and I have some DependencyProperties in my window's

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.