This is a migrated thread and some comments may be shown as answers.

PropertyGrid AutoGeneratePropertyDefinitions=true

4 Answers 139 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mahesh
Top achievements
Rank 1
Mahesh asked on 01 Feb 2012, 01:54 AM
I am trying to use a PropertyGrid for setting properties of various object types.
My requirement is that for a given property, I should be able to select Value from the RadComboBox and set it on the property of a given object.
I dont want to assign it based on ProprtyName and hardcode it in event handler, so I am setting custom attributes on properties and using them to assign perticular template for a given attribute.
I have defined the DataTemplate in xaml and assining it in codebehind in AutoGeneratingPropertyDefinition event handler.

I want to use same template for different properties might be with some slight change. i.e. Onlt SelectedValue path has to be changed in a below template.

<DataTemplate x:Key="DataProviderTemplate"> 
 <telerik:RadComboBox ItemsSource="{Binding Source={StaticResource DataContextProxy}, Path=DataSource.DataSources}"  DisplayMemberPath="Name" SelectedValuePath="Name"  SelectedValue="{Binding Path=PermissionedUserSearchTextBoxDPName, Mode=TwoWay}" Margin="2,0,0,0" VerticalAlignment="Center">  </telerik:RadComboBox>

</DataTemplate>

CodeBehind in event handler is
DataTemplate dt = LayoutRoot.Resources["DataProviderTemplate"] as DataTemplate; 

e.PropertyDefinition.EditorTemplate = dt;

But I am facing issue of binding PropertyValue in the template.

I also tried changing RadComboBox.SelectedValue's binding path in template using code behind, but it is of not much help.

Please advice.

 

 

4 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 01 Feb 2012, 10:40 AM
Hi Mahesh,

Everything seems correctly set in the code-snippets you provided. Can you provide a bit more details what is the exact behavior that you experience - is the source not available, is the selected value not selected initially ? Can you select an item afterwards ? 

Kind regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Mahesh
Top achievements
Rank 1
answered on 01 Feb 2012, 04:54 PM
Maya - Code given in#1 work for given single property.
But in the given code, at runtime, I want to set Path for each property. I dont want to have seperate template for each property which is autogenerated.
SelectedValue="{Binding Path=City1, Mode=TwoWay}"

My requirement is, I want to set property from the given options in dropdown. Say I have 3 properties like City1, Ciity2, and City3. For all these 3 properties, I want to set city name from a dropdown
i,e City1= New york, City2=Boston, City3=Mumbai. All these cities are to be selected from dropdown showing all cities.
City1 => Select from city combobox ( list of US cities)
City2 => Select from city combobox ( list of US cities)
City3 => Select from city combobox ( list of US cities)
Once selected in dropdown the property value should be set & dispalyed in combobox.

I am open for any option that will
1. Single EditTemplate that can be used for all these 3 properites
2. Allow me to use my own list of Cities that is in ViewModel which is binded to UserControl that holds PropertyGrid.

Currently I am using one single template for all these 3 properties, but its not helping due to hardcoded path.

hope this helps.
0
Mahesh
Top achievements
Rank 1
answered on 02 Feb 2012, 04:13 PM
telerik support - any inputs on above issue??
0
Maya
Telerik team
answered on 06 Feb 2012, 02:23 PM
Hi Mahesh,

We will introduce a new feature for defining a data template for different properties in our next official release Q1 2012 (it will be available in the middle of February). Thus you will be able to achieve your scenario just by using the attached behavior (AutoBindBehavior). Once the release is available, you will be able to find an example in our demos as well.  

Greetings,
Maya
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
PropertyGrid
Asked by
Mahesh
Top achievements
Rank 1
Answers by
Maya
Telerik team
Mahesh
Top achievements
Rank 1
Share this question
or