Wpf Mvvm Entity Framework database-first Binding
up vote
-1
down vote
favorite
I'm building an app using Wpf Mvvm Entity Framework database-first. My model is auto generated so I can't put the NotifyPropertyChanged in the entity.. so I rewrite all the stuff in my viewModel witch is ugly..
I don't think I'm clear so a sample of code, won't post everything for more clarity.
The user control
<TextBox Name="tbClientNumber" Text="Binding ClientNumber,
UpdateSourceTrigger=PropertyChanged, Mode=TwoWay"/>
The ViewModel class:
public class ClientManagerViewModel : BaseViewModel
public int ClientNumber
get return _clientNumber;
set
_clientNumber= value;
RaisePropertyChanged("ClientNumber");
Auto-generated entity:
public partial class Client
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Client()
public int idClient get; set;
public int ClientNumber get; set;
Thank you all in advance
c# wpf mvvm entity-framework-6 inotifypropertychanged
add a comment |
up vote
-1
down vote
favorite
I'm building an app using Wpf Mvvm Entity Framework database-first. My model is auto generated so I can't put the NotifyPropertyChanged in the entity.. so I rewrite all the stuff in my viewModel witch is ugly..
I don't think I'm clear so a sample of code, won't post everything for more clarity.
The user control
<TextBox Name="tbClientNumber" Text="Binding ClientNumber,
UpdateSourceTrigger=PropertyChanged, Mode=TwoWay"/>
The ViewModel class:
public class ClientManagerViewModel : BaseViewModel
public int ClientNumber
get return _clientNumber;
set
_clientNumber= value;
RaisePropertyChanged("ClientNumber");
Auto-generated entity:
public partial class Client
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Client()
public int idClient get; set;
public int ClientNumber get; set;
Thank you all in advance
c# wpf mvvm entity-framework-6 inotifypropertychanged
Hi there, what's the issue you want to avoid? Ugly is not a good description. Please write what exactly you want to achieve
– Jan
Nov 10 at 4:44
You appear to want your Model to be a ViewModel. (I'm assuming you understand what the letters in MVVM represent.) This may mean you haven't grasped the reason for them being separate.
– Richardissimo
Nov 10 at 7:46
I thought viewmodel doesn't know anything about the view, so if i put all the property in viewModel, properties that are already existing somewhere, it sounds to me that's incorrect for the design pattern. I describe it as ugly for that reason..
– miniboom
Nov 10 at 19:13
You can put the entities and wrappers on model layer. View model will have a propertyClientWrapperand the binding will be likeText="Binding ClientWrapper.ClientNumber, ... ". This might help you stackoverflow.com/questions/17143842/…
– cactuaroid
Nov 11 at 7:22
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I'm building an app using Wpf Mvvm Entity Framework database-first. My model is auto generated so I can't put the NotifyPropertyChanged in the entity.. so I rewrite all the stuff in my viewModel witch is ugly..
I don't think I'm clear so a sample of code, won't post everything for more clarity.
The user control
<TextBox Name="tbClientNumber" Text="Binding ClientNumber,
UpdateSourceTrigger=PropertyChanged, Mode=TwoWay"/>
The ViewModel class:
public class ClientManagerViewModel : BaseViewModel
public int ClientNumber
get return _clientNumber;
set
_clientNumber= value;
RaisePropertyChanged("ClientNumber");
Auto-generated entity:
public partial class Client
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Client()
public int idClient get; set;
public int ClientNumber get; set;
Thank you all in advance
c# wpf mvvm entity-framework-6 inotifypropertychanged
I'm building an app using Wpf Mvvm Entity Framework database-first. My model is auto generated so I can't put the NotifyPropertyChanged in the entity.. so I rewrite all the stuff in my viewModel witch is ugly..
I don't think I'm clear so a sample of code, won't post everything for more clarity.
The user control
<TextBox Name="tbClientNumber" Text="Binding ClientNumber,
UpdateSourceTrigger=PropertyChanged, Mode=TwoWay"/>
The ViewModel class:
public class ClientManagerViewModel : BaseViewModel
public int ClientNumber
get return _clientNumber;
set
_clientNumber= value;
RaisePropertyChanged("ClientNumber");
Auto-generated entity:
public partial class Client
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Client()
public int idClient get; set;
public int ClientNumber get; set;
Thank you all in advance
c# wpf mvvm entity-framework-6 inotifypropertychanged
c# wpf mvvm entity-framework-6 inotifypropertychanged
edited Nov 10 at 7:31
marc_s
567k12810961246
567k12810961246
asked Nov 10 at 4:29
miniboom
11
11
Hi there, what's the issue you want to avoid? Ugly is not a good description. Please write what exactly you want to achieve
– Jan
Nov 10 at 4:44
You appear to want your Model to be a ViewModel. (I'm assuming you understand what the letters in MVVM represent.) This may mean you haven't grasped the reason for them being separate.
– Richardissimo
Nov 10 at 7:46
I thought viewmodel doesn't know anything about the view, so if i put all the property in viewModel, properties that are already existing somewhere, it sounds to me that's incorrect for the design pattern. I describe it as ugly for that reason..
– miniboom
Nov 10 at 19:13
You can put the entities and wrappers on model layer. View model will have a propertyClientWrapperand the binding will be likeText="Binding ClientWrapper.ClientNumber, ... ". This might help you stackoverflow.com/questions/17143842/…
– cactuaroid
Nov 11 at 7:22
add a comment |
Hi there, what's the issue you want to avoid? Ugly is not a good description. Please write what exactly you want to achieve
– Jan
Nov 10 at 4:44
You appear to want your Model to be a ViewModel. (I'm assuming you understand what the letters in MVVM represent.) This may mean you haven't grasped the reason for them being separate.
– Richardissimo
Nov 10 at 7:46
I thought viewmodel doesn't know anything about the view, so if i put all the property in viewModel, properties that are already existing somewhere, it sounds to me that's incorrect for the design pattern. I describe it as ugly for that reason..
– miniboom
Nov 10 at 19:13
You can put the entities and wrappers on model layer. View model will have a propertyClientWrapperand the binding will be likeText="Binding ClientWrapper.ClientNumber, ... ". This might help you stackoverflow.com/questions/17143842/…
– cactuaroid
Nov 11 at 7:22
Hi there, what's the issue you want to avoid? Ugly is not a good description. Please write what exactly you want to achieve
– Jan
Nov 10 at 4:44
Hi there, what's the issue you want to avoid? Ugly is not a good description. Please write what exactly you want to achieve
– Jan
Nov 10 at 4:44
You appear to want your Model to be a ViewModel. (I'm assuming you understand what the letters in MVVM represent.) This may mean you haven't grasped the reason for them being separate.
– Richardissimo
Nov 10 at 7:46
You appear to want your Model to be a ViewModel. (I'm assuming you understand what the letters in MVVM represent.) This may mean you haven't grasped the reason for them being separate.
– Richardissimo
Nov 10 at 7:46
I thought viewmodel doesn't know anything about the view, so if i put all the property in viewModel, properties that are already existing somewhere, it sounds to me that's incorrect for the design pattern. I describe it as ugly for that reason..
– miniboom
Nov 10 at 19:13
I thought viewmodel doesn't know anything about the view, so if i put all the property in viewModel, properties that are already existing somewhere, it sounds to me that's incorrect for the design pattern. I describe it as ugly for that reason..
– miniboom
Nov 10 at 19:13
You can put the entities and wrappers on model layer. View model will have a property
ClientWrapper and the binding will be like Text="Binding ClientWrapper.ClientNumber, ... ". This might help you stackoverflow.com/questions/17143842/…– cactuaroid
Nov 11 at 7:22
You can put the entities and wrappers on model layer. View model will have a property
ClientWrapper and the binding will be like Text="Binding ClientWrapper.ClientNumber, ... ". This might help you stackoverflow.com/questions/17143842/…– cactuaroid
Nov 11 at 7:22
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
If you don't want to wrap the entity classes, Fody might help you. You can implement INotifyPropertyChanged on a partial class definition. I have not tried yet though.
All classes that implement INotifyPropertyChanged will have notification code injected into property setters.
https://github.com/Fody/PropertyChanged
Actually I usually simply wrap them like you did.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
If you don't want to wrap the entity classes, Fody might help you. You can implement INotifyPropertyChanged on a partial class definition. I have not tried yet though.
All classes that implement INotifyPropertyChanged will have notification code injected into property setters.
https://github.com/Fody/PropertyChanged
Actually I usually simply wrap them like you did.
add a comment |
up vote
0
down vote
If you don't want to wrap the entity classes, Fody might help you. You can implement INotifyPropertyChanged on a partial class definition. I have not tried yet though.
All classes that implement INotifyPropertyChanged will have notification code injected into property setters.
https://github.com/Fody/PropertyChanged
Actually I usually simply wrap them like you did.
add a comment |
up vote
0
down vote
up vote
0
down vote
If you don't want to wrap the entity classes, Fody might help you. You can implement INotifyPropertyChanged on a partial class definition. I have not tried yet though.
All classes that implement INotifyPropertyChanged will have notification code injected into property setters.
https://github.com/Fody/PropertyChanged
Actually I usually simply wrap them like you did.
If you don't want to wrap the entity classes, Fody might help you. You can implement INotifyPropertyChanged on a partial class definition. I have not tried yet though.
All classes that implement INotifyPropertyChanged will have notification code injected into property setters.
https://github.com/Fody/PropertyChanged
Actually I usually simply wrap them like you did.
answered Nov 10 at 6:59
cactuaroid
34119
34119
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53236001%2fwpf-mvvm-entity-framework-database-first-binding%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Hi there, what's the issue you want to avoid? Ugly is not a good description. Please write what exactly you want to achieve
– Jan
Nov 10 at 4:44
You appear to want your Model to be a ViewModel. (I'm assuming you understand what the letters in MVVM represent.) This may mean you haven't grasped the reason for them being separate.
– Richardissimo
Nov 10 at 7:46
I thought viewmodel doesn't know anything about the view, so if i put all the property in viewModel, properties that are already existing somewhere, it sounds to me that's incorrect for the design pattern. I describe it as ugly for that reason..
– miniboom
Nov 10 at 19:13
You can put the entities and wrappers on model layer. View model will have a property
ClientWrapperand the binding will be likeText="Binding ClientWrapper.ClientNumber, ... ". This might help you stackoverflow.com/questions/17143842/…– cactuaroid
Nov 11 at 7:22