This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Ok, I am trying to implement MVC framework in WPF and have my 1) Model - which will hold my objects 2) BaseController - which inherits the DependencyObject 3) {ViewSpecific}Controller - there would be a controller for each view and the {ViewSpecific} will replace that view's name. I am using DependencyProperty to keep track of my objects and also have a RoutedUICommand. Here is how my LoginController will look like (just a sample) public class LoginController : BaseController .............. So, now I have a login form which has username,password fields and also a button Login. I am going to give this RoutedUIEvent as the command for the button and want to pass the LoginObject as my CommandParameter...and there comes my problem If I can pass on the Property Grid's ItemSource (which would be bound to the Type LoginObject and use a DataTemplate where I just have two labels and two textbox for user name and password respectively), as the CommandParameter, then now I can handle them. But unless I bound data with the Property Grid, it wont be displayed in the form. If there are data associated with the bound type, we immediately see that the Property Grid picks it up (when supplied as ItemSource) and displays them...but I want in a way that display the Property Name eventhough it doesn't contain any values but be bound to the UI elements in the Grid.. I hope I am clear here....can this be done using Property Grid? |
|
|
Hi Chaks, Thanks for emailing me with the additional detail. I'll post the response here so it's for the ages. You're trying to use a type editor to set up a custom template for the user to edit LoginObjects. For this to work, the LoginObject must be a property of the SelectedObject (or a node added using AddNode, or a value in the ItemsSource dictionary). That is, type editors don’t tell the grid what to display if the SelectedObject is of that type; they tell the grid what to display for a *property* (or, more generally, a node) whose value is of that type. So your approach will work only if propertyGrid.SelectedObject is set to something which has a LoginObject as one of its properties (e.g. perhaps SelectedObject represents a resource connection and the LoginObject is its Credentials property). Note also that in this case your template will appear in the “value” column of the grid. So if we are talking about a login dialog, where all you want to do is get the user's name and password, then you should set grid.SelectedObject = myLoginObject, and use property editors and styles for any visual customisation. (Note that, for a case as simple as this, such customisation will probably be more effort than just using your DataTemplate directly, so you will need to consider whether there are longer-term benefits that justify that effort.) If we are talking about a larger object which has a LoginObject as one of its attributes, then what you're doing will work. You were also interested in accessing the names of the LoginObject properties from the type editor. Cheers, Ivan |
|
|
Hi Ivan , Thanks for the reply. As you said, I think I will use Property Grid where I can take its full advantage than in this login screen and I have already deduced a good way for this Login Screen :) But after the login screen...there is dashboard where data is displayed and I am sure I can use Property Grid there...
|
|