I've searched the web for some introductory tutorial about the Extended WPF Toolkit PropertyGrid (http://wpftoolkit.codeplex.com) and custom attributes but didn't find. I've also downloaded the source code with the samples inside but that didn't help either. I'm a beginner with WPF so i might be missing something simple here. What i want to do is to create a simple Property Grid with some custom attributes. Does someone have a code snippet of something simple like a Property Grid with two attributes like Name and Age that are associated with some class like Person. I've already tried the snippet that they provide in the PropertyGrid documentation page on Codeplex but i couldn't get it to work. I've managed to put the Property Grid appear on the UI, but that's all, no custom attributes.
And your Name, Age are string/int types.. So if you assign your object as SelectedObject to PropertyGrid- it must do just fine. For example here is my code where i show application settings as property grid to the user:
wpf:
<extToolkit:PropertyGrid
Name="PropertyPanel"
IsManipulationEnabled="True"></extToolkit:PropertyGrid>
codebehind:
PropertyPanel.SelectedObject = Properties.Settings.Default;
PopertyGrid assigns templates automatically, depending on property type.
Related
I am trying to give access to Chart control's properties through PropertyGrid. I'd like to localize it. Is that possible without writing another class, that will mimic most of this control properties and have my custom property display names and descriptions?
P.S.
I know that it is not a good idea to give user "full control" over a UI control through PropertyGrid, but it's not my idea ...
I am aiming at creating different UserControls for my college project, in which I am attempting to use ContentControl to wrap my UserControl. I've placed other Controls like Image, WebBrowser, MediaElement and the like, now I have reached a stage where I need to set the properties for my UserControls. Thus, I thought of making use of PropertyGrid Control, but now the problem I am facing is in the PropertyGrid control, as I get all the default properties of the Controls, which in my case I don't want.
For Eg: if I use Image Control then i need properties like Source and Stretch to be displayed only in the PropertyGrid. Can anyone help me in achieving this?
I tried to override some default properties like "Name" and assign it as [Browsable(false)] to hide it from being displayed. I don't want to do this for all the other properties which are being displayed and which are not under my requirements as well.
I am using Xceed.Wpf.Toolkit for my PropertyGrid.
It is explained in the documentation on how to do that:
http://wpftoolkit.codeplex.com/wikipage?title=PropertyGrid
When you change the selected object see SelectedObjectType and set PropertyDefinitions in code to match the properties you want to see for that type of object.
The default "split view" template for a Metro application written in C# makes use of an ItemTemplate attribute in the ListView tag. I'm just getting started with XAML and C#, so it's all still a bit overwhelming.
I understand that the ItemsSource is used to provide the data collection to the view, but I'm a bit confused as to how the ListView knows what to display from those model classes. Is this defined by the ItemTemlate? There's a snippet of code:
...ItemTemplate="{StaticResource SnapListItemTemplate}" ItemContainerStyle="{StaticResource SnapListTileStyle}" ItemsPanel="{StaticResource SnapListItemsPanelTemplate}"...
I don't really understand most of that line. Where are these SnapList* options defined? Is there a provided list of available templates, or are these all defined my project somewhere? Does the SnapListItemTemplate look for a specific set of ivars to display? Can this template be altered or "subclassed"?
For example, there are a number of properties on the model classes like title, subtitle, etc. And I'm curious as to how the ListView knows to pull out those specific values, and also how it knows to lay them out. What if I want to change the name of the subtitle ivar to subtext? How is the item template updated?
The SnapList* templates should be defined in your project somewhere.
The binding is {StaticResource ...} which means that the template/style or whatever is usually defined in some XAML file.
If you search the project (Ctrl+Shift+F) for the names they should turn up, probably in a file called Styles.xaml.
I'm having a WPF Custom Control which represents me a given point on a plan (I'm making a guide application for my studies) and I want it to looks different for different categories of the objects represented by this map node (i.e. toilet, lift or normal room).
Could anyone give me some idea how to do this?
I tried creating a Converter but it didn't goes well.
Also my problem is that sometimes in could be the WPF element like Ellipse and sometimes it should be an image.
Is it somehow possible to create custom control with multiple templates and the template will be selected depending on some category attribute?
For things like this, you might want to have a look at the DataTemplateSelector class. It allows you to select the datatemplate based on the actual object you are binding to.
Here's a tutorial for it, but i'm sure you can find more on the internet:
http://www.switchonthecode.com/tutorials/wpf-tutorial-how-to-use-a-datatemplateselector
I've got an ObservableCollection of POCOs (Plain old CLR Objects) that I want to represent in a tabbed idiom. Prefereably using the MVVM pattern, is there a way to bind the collection of TabItems to the count of my POCO collection?
So, in this case if there are 3 items in my collection, I'd like to see 3 TabItems. Each TabItem would contain the same controls in the same location, each control bound to properties of the appropriate object in the collection.
I'm just looking for an overview of the approach I might use or a link to an example. If you need more info, feel free to ask.
Thanks.
I'd probably create an ObservableColletion with your POCO items in it. You could then bind that ObservableCollection to any of the Silverlight Item Rendering controls. You'll have to modify the default rendering template to create your tabs...but using that method, your tabs will constantly be up to date with the items in the collection without having to put any code in the code behind file.
UPDATE
Here's a link to the Silverlight Forums where somebody built a TabControl using the ItemsControl with sample XAML code:
http://silverlight.net/forums/t/12271.aspx
...just scroll down a bit to see the sample.
One way to do this is to use a value converter (IValueConverter) to return your POCO wrapped in a TabItem. I posted an example here as part of a related question. There is also sample xaml binding and injection of the ViewModel as a parameter to the value converter.
/jhd