Click here to Skip to main content
15,895,538 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: How do I databind a ListView to a property in child collection in WPF? Pin
B2C4-May-11 5:15
B2C4-May-11 5:15 
GeneralRe: How do I databind a ListView to a property in child collection in WPF? Pin
SledgeHammer014-May-11 7:00
SledgeHammer014-May-11 7:00 
GeneralRe: How do I databind a ListView to a property in child collection in WPF? Pin
AspDotNetDev4-May-11 7:59
protectorAspDotNetDev4-May-11 7:59 
AnswerRe: How do I databind a ListView to a property in child collection in WPF? Pin
Ian Shlasko4-May-11 5:40
Ian Shlasko4-May-11 5:40 
QuestionPrintable Area's Size - SL Printing API Pin
jadughar4-May-11 0:38
jadughar4-May-11 0:38 
AnswerRe: PageVisual's Size - SL Printing API Pin
Pete O'Hanlon4-May-11 2:18
mvePete O'Hanlon4-May-11 2:18 
GeneralRe: PageVisual's Size - SL Printing API Pin
jadughar4-May-11 4:24
jadughar4-May-11 4:24 
QuestionMVVM Pin
arkiboys3-May-11 22:50
arkiboys3-May-11 22:50 
Hi,
I have completed a WPF application in c#.
Now, I would like to start using the MVVM design pattern in this application.

At present, One of the windows forms i.e. frmPayment is populated as follows:
private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DataTable _dtPayments = GetPayments(_intID);
                DataView defaultView = _dtPayments.DefaultView;

                dgPayments.ItemsSource = defaultView;
        }

////////////////////////////////////////////////////////

Now, to get started with the MVVM, I have created a class called clsPaymentViewModel
with the following code:
public class clsPaymentViewModel : INotifyPropertyChanged
    {
        clsPaymentManager _PaymentManager = new clsPaymentManager();

        public clsPaymentViewModel(int intID)
        {
            DataCollection = _PaymentManager.GetPayments(intID);
        }

        #region INotifyPropertyChanged
        public event PropertyChangedEventHandler PropertyChanged;

        protected void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
        #endregion

        private ObservableCollection<clsPayment> mDataCollection;

        public ObservableCollection<clsPayment> DataCollection
        {
            get { return mDataCollection; }
            set
            {
                mDataCollection = value;
                RaisePropertyChanged("DataCollection");
            }
        }

    }
/////////////////////////////////////////////////////////
    {
        public ObservableCollection<clsPayment> GetPayments(int intID)
        {
            ObservableCollection<clsPayment> ret;

            List<clsPayment> payments = GetPaymentsCol(intID);

            ret = new ObservableCollection<clsPayment>(payments);
            return ret;
        }

    }

public class clsPaymentManager
frmPayment has this code in it:

clsPaymentViewModel _ViewModel;

public frmPayment()
        {
            InitializeComponent();

            int _intID = 1
            _ViewModel = new clsPaymentViewModel(_intID);
        }

//////////////////////

QUESTION:
Based on the above code, what should the DataContext be for dgPayment in frmPayment?
I was thinking of putting something like:
DataContext="{Binding Source={StaticResource clsPaymentViewModel}}"
But this is not right because there should be a _intID
What do you think please?
Thanks
AnswerRe: MVVM Pin
Dave Kerr3-May-11 23:09
mentorDave Kerr3-May-11 23:09 
GeneralRe: MVVM Pin
arkiboys3-May-11 23:19
arkiboys3-May-11 23:19 
QuestionSilverlight Compatibility with existing C#2.0 libraries Pin
insanechingi3-May-11 22:14
insanechingi3-May-11 22:14 
AnswerRe: Silverlight Compatibility with existing C#2.0 libraries Pin
Pete O'Hanlon3-May-11 23:14
mvePete O'Hanlon3-May-11 23:14 
QuestionSilverlight best Printing solution ??? Pin
jadughar2-May-11 4:08
jadughar2-May-11 4:08 
AnswerRe: Silverlight best Printing solution ??? Pin
Pete O'Hanlon2-May-11 9:40
mvePete O'Hanlon2-May-11 9:40 
AnswerRe: Silverlight best Printing solution ??? Pin
Mycroft Holmes2-May-11 13:10
professionalMycroft Holmes2-May-11 13:10 
GeneralRe: Silverlight best Printing solution ??? Pin
jadughar3-May-11 23:36
jadughar3-May-11 23:36 
AnswerRe: Silverlight best Printing solution ??? Pin
Abhinav S2-May-11 18:59
Abhinav S2-May-11 18:59 
GeneralRe: Silverlight best Printing solution ??? Pin
jadughar2-May-11 22:32
jadughar2-May-11 22:32 
AnswerRe: Silverlight best Printing solution ??? Pin
thrakazog3-May-11 6:25
thrakazog3-May-11 6:25 
AnswerRe: Silverlight best Printing solution ??? Pin
jadughar3-May-11 20:58
jadughar3-May-11 20:58 
GeneralRe: Silverlight best Printing solution ??? Pin
Mycroft Holmes3-May-11 21:53
professionalMycroft Holmes3-May-11 21:53 
GeneralRe: Silverlight best Printing solution ??? Pin
Abhinav S3-May-11 22:09
Abhinav S3-May-11 22:09 
GeneralRe: Silverlight best Printing solution ??? Pin
Mycroft Holmes3-May-11 22:50
professionalMycroft Holmes3-May-11 22:50 
GeneralRe: Silverlight best Printing solution ??? Pin
Abhinav S3-May-11 23:10
Abhinav S3-May-11 23:10 
QuestionUpdate Domain context Pin
picasso230-Apr-11 14:51
picasso230-Apr-11 14:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.