|
Using an action delegate would work of course, but it introduces tight coupling between view models which is a no-no. vmA has to know explicitly about vmB and explicitly subscribe to the event. Messenger doesn't have that problem since its more "anonymous". All your VM is coupled too is the messenger service. And if you are using DependencyInjection that can be a loose coupling as well.
|
|
|
|
|
There's still one issue to solve on this.
When a RecentProjects link in the child view is clicked, I need to send a message to the MainWindowViewModel to open the project. But how do I pass the ProjectId as a param? I'm using MVVM Light Toolkit from Galasoft, but I don't know it passing params is an option. Ever done this before?
Everything makes sense in someone's mind
|
|
|
|
|
I've looked at MVVM Light, but haven't used it specifically. They do have a Messenger service, that I do know. I think you just derive an object from one of their base classes and you can pass whatever data you want.
|
|
|
|
|
I want to display some text on a user control that is dynamic in what is says, and also that would have hyperlinks in it.
How do I do this?
Everything makes sense in someone's mind
|
|
|
|
|
1) FlowDocument
2) WebBrowser
3) TextBlock using Runs
4) google for WPF LinkLabel control
|
|
|
|
|
Actually I just came up with the same idea,
I used a flowpanel and a series of lables & hyperlinks.
Thanks
Everything makes sense in someone's mind
|
|
|
|
|
Validation in Windows Presentation Foundation[^]
and
http://msdn.microsoft.com/en-us/library/0c899ak8.aspx[^]
were both good resources for custom validation rules on a DataGrid, but if I programmatically change values in the row source, the row doesn't re-validate. If I change a cell value by manually editing it, on the other hand, validation will fire.
How can I force validation even when the user is not directly manipulating the cell?
I have my custom validation rule ValidationStep set to CommittedValue and UpdatedValue.
I've also tried BeginEdit and CommitEdit after changes are made.
Any thoughts?
|
|
|
|
|
Does the class representing a row of data implement and use the INotifyPropertyChanged interface?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
It's an EF ComplexObject using the default auto generated code. It is derived from StructuralObject, which is derived from INotifyPropertyChanging and implements the INotifyPropertyChanged.
I checked the Properties I'm changing and they all call the ReportPropertyChanged method after a change occurs.
I think this has more to do with the way I'm updating the row source. I'm allowing the user to open a context menu through the ValidationErrorTemplate and select various options. The change occurs in the MenuItem click event. If I change focus to anything in the Window using the mouse, the row will validate.
|
|
|
|
|
|
You're right. I'm not using the validator as intended. There are plenty of things I can do in a cell data template to get my intended functionality. Thanks for the help. It didn't get me to my original goal, but illuminated the error of my ways and saved me time digging for an answer that doesn't exist.
|
|
|
|
|
Hi,
Is there a free ribbon tool bar? Can I use MS office ribbon control in the siverlight apps?
Best regards,
|
|
|
|
|
There are plenty of free ribbons including one from Microsoft that is going to be a part of .NET 4.5, but you can download it separately for now. Unfortunately, you are going to find that you get what you pay for and that these free ribbons aren't quite as polished and performant as some of the paid ones . If all you are looking for is the actual ribbon itself without any of the supporting UI elements (color themes, scrollbars, ribbon windows, etc) the Microsoft one will do.
|
|
|
|
|
Here's one I've used. They did an excellent job with it. It has a few minor issues but most all of them can be worked around.
http://fluent.codeplex.com/[^]
|
|
|
|
|
Hello Everyone,
I am not able to capture Automation ID of ITEMS of ListControls such as Combobox,Listbox ,Listview , TreeView.. in QTP for Automation for WPF project.
Can any one tell me how can I get the Automation ID or how can I identify the ITEMS of WPF list controls in QTP Automation TEST since List conrols are being filled dynamically?
Regards,
Ashish
|
|
|
|
|
Hello Everyone,
My WPF application needs to be automated but I do not have assigned AutomationID property to controls.Its in .NET 3.5 and Its very tedious to assign such unique ID to every control.Application will be Automated by QTP.
Is there any short way using which I can assing this unique ID property to all my conrols?
or any way to assign AutomationID property to Conrols?
Regards,
Ashish Parmar
|
|
|
|
|
See if you can use the control key or name instead.
|
|
|
|
|
Since the list/Item conrols are being loaded dynamically, I want to know how do i get AutomationID of these Items in QTP?
QTP is not able to identify these AutomationID..
For Ex: I have a listview which is loaded from datacontext at run time. I am not able to capture items of Listview in QTP.
|
|
|
|
|
This one will be easy, I guess.
Suppose I have a model class, for example Day, with its properties. Then I have DayViewModel, which wraps the Day for viewing, presents some other properties which are not present in the model class (like TimeOfSunset which can be computed, whatever, it's an example).
Then I have Week class, which is a collection of Day objects + additional properties. Then again, WeekViewModel which wraps Week for viewing. I am not doing this automatically - one VM class for each M class, I really need to show Days (in a list maybe), hence the DayViewModel, and I want to show and interact with Weeks, hence the WeekViewModel.
Now to the question. The Week class must include some property like List<Day> Days; which will be populated when the Week is loaded from the data store. But WeekViewModel requires something more like ObservableCollection<DayViewModel> . Now this is awkward, I already have one collection and I need to create another with the same physical data, just to change Day to DayViewModel and List to ObservableCollection. I could live with that but it gets worse. Whenever the WeekViewModel's ObservableCollection gets changed, I must take care to change the Week's List accordingly so that when I save the model classes to the data store, I am sure to have the most recent version.
What is the common way to deal with this simple scenario? I believe that one of the benefits of MVVM is the fact, that several ViewModels can work with one Model just like several Views can work with one ViewModel (correct me if I am wrong). Following this principle, I can't simply use ObservableCollection<DayViewModel> directly in the Week (model) class, because that would tie the Model with one particular ViewModel.
So, is there a better way around this than the one I outlined? I'll be happy to hear your suggestions, H.
|
|
|
|
|
What you could do is something along the lines of
DateViewModel(string Week, ObservableCollection<Days> Days)
Making DateViewModel a class.
I believe this would give you the functionality you are looking for.
Or even possibly
DateViewModel(ObservableCollection<Week> Week, ObservableCollection<Days> Days)
|
|
|
|
|
I see I didn't express myself clearly. It is not really a functionality I am looking for, more like advice on how to deal with the given scenario using MVVM. If I ditch MVVM, I am ok.
Another approach to explaining the question: how to work with two-layer model data in MVVM framework.
As an abstract example - consider a SubItem class (model) and associated SubItemViewModel, then I have Item class (model; containing a collection of SubItems) and associated ItemViewModel. The application works with a collection of Items (we may call this application-level class SuperItemViewModel).
Like I explained in the original post, the model classes consist of ordinary collections of another model classes while the view-model classes contain observable collections of associated view-model classes (this is how I understand MVVM, which may be wrong).
My question is, how to best plug these M and VM classes together while maintaining sufficient separability. That is, in the imaginary Item model class I could directly use ObservableCollection of SubItemViewModels but this, in my understanding, has no place in model classes, which are supposed to be unaware of view-models.
To say it most generally, I think I understand the V-VM part but I don't really get the M-VM part.
Hope I made myself clearer. If not, I may give up this thread and MVVM altogether
Thanks for any suggestions.
|
|
|
|
|
This is where people go wrong with MVVM. Over thinking things. Over engineering things. Why do you need a Day AND a DayModel? A Day IS a DayModel. You should most certainly NOT have a DataProvider that returns a POCO object and then have your UI wrap it in a model type clas. Your DataProvider should return an object that implements INPC in some form.
There is also no such rule that says you have to have 1:1 relationship between M and VM. A VM can most certainly use / expose 2 or 20 M's.
-- modified 14-Oct-11 11:37am.
|
|
|
|
|
If the OP doesn't want a simplified answer, he shouldn't post a simplified question. Its not the forums job to read his mind. Based on what he/she posted, there was nothing about any such restrictions or limitations and I interpreted him/her to be a MVVM newbie who like the rest of us started off a project with the goal of having "perfect" code and seperating everything out "perfectly". It sounded like the OP simply didn't know where to draw the MVVM line in the sand as opposed to constantly down voting people who didn't precisely agree with him.
|
|
|
|
|
Actually, my response was 100% correct given the information the poster gave. Whether he said it was an example or not is irrelevant. He did not indicate that code involved was not his or off limits. Had he responded to my response with that fact, I may have provided a different answer.
For now, I will stand by my response that separating the data layer into a POCO and a M just for the sake of doing so (thinking it is a good separation of duty) is completely un-necessary and completely over-engineered and it would have completely solved his problem of converting between a Day and a DayModel.
Just as I will stand by my other response (that you also down voted) that the use of partial classes is completely proper. If you hate partial classes, well, you better go and explain yourself to Bill Gates (er, Steve Balmer) because pretty much ALL his technologies use them. Winforms, WPF, WCF, ADO.NET, etc.
EDIT: BTW, I gave your post a 3 (should have probably gone lower though) because it was an abuse of technology given the scenario. Use of factories and DI for such a simple problem? Really? Why not go even further and use a remote https server behind a firewall using 512 bit encryption and a separate validation server to ensure the object is valid?
|
|
|
|
|
Collin Jasnoch wrote: Your respnoce was simply a "You shouldn't do that." Nothing more nothing less.
No explanation other than the claim of over engineering.
Actually, my response was that they should be the same object and not two different ones which would solve the OPs problem. Given the info the OP posted, this was the correct answer.
Collin Jasnoch wrote: So, how are you going to handle a 3rd party controlled model? Or an object that
you control that is used elsewhere and has embedded objects of which are not
INOC? You make the assumption that the developer controls all aspects. In
reality most patterns (Including MVVM) are created because we can not control
all components. For the few, hey great. Code how you want. For the rest of the
world we follow the patterns for easy transition, upgrades, extensions, testing
etc. etc. etc
Who asked about 3rd party components? Certainly not the OP. Quit making up imaginary scenarios to justify your answer. Until the OP says that he is using 3rd party components that are not designed for MVVM, your point is completely irrelevant to the OPs question.
Where do you get off saying I don't follow design patterns? I certainly do. I don't spend a month implementing a design pattern when a 5 minute "shortcut" will work "for now". I certainly don't write all my code using "shortcuts" or I wouldn't even use MVVM.
Collin Jasnoch wrote: I doubt you have actually implimented a large scale MVVM project. The poster
asked what is the common way to deal with that scenerio (you may want to go back
and look... cause again you did not answer his question. You said he is over
engineering).
Where do you get off saying what I have implemented or not? I'm actually working on a large scale MVVM project right now and yes, I am using 100% proper MVVM with DI, messenger to communicate between views, etc. I use technologies where appropriate. Not to feed my ego like you obviously do.
Collin Jasnoch wrote: You stating it is an abuse of technology is like stating OOP should not be used
in simple apps. If you don't understand that, then it is likely you really don't
understand what DI is.
Lol... you need help bro. Go see a therapist. I certainly know what DI is. In fact, I have personally implemented a DI container. Have you?
Collin Jasnoch wrote: First off, your claim here is insane. Do you really think Gates or Balmer
invented those platforms??? Secondly they use them only in 'AUTO GENERATED
CODE'. The purpose is quite obvious (well atleast to most I guess). If I have
some auto generated code that resides in the same file as that which the
developer is modifying I have a high risk of the developer modifying code that
will be overritten when 'AUTO GENERATED' again. Or it is possible the developer
simple breaks the logic because they do not fully understand the logic flow or
meaning of the code. This was why partial classes were created and this is WHEN
they should be used. Not because you want to EXTEND a class. In fact, there is a
thing called Extensions[^]. In any other case you should be refactoring and
making new objects.
Your mental issues are coming out again. Did I ever claim Gates or Balmer invented WPF? I said that Microsoft uses partial classes everywhere. I'll certainly listen to Microsoft and follow their advice before I listen to you and your insane rants.
Who ever said anything about modifying auto-generated classes? Thats dumb.
Seems like Microsoft disagrees with you, yet again... here... I'll post the link for you so you can read up on partial classes:
http://msdn.microsoft.com/en-us/library/wa80x488.aspx[^]
|
|
|
|