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

[Solved] Custom Editor in AutoGeneratingPropertyDefinition Event

9 Answers 252 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.
Robert
Top achievements
Rank 1
Robert asked on 16 Nov 2012, 10:06 AM
Hi,
Could someone tell me what is changed about RadPropertyGrid  in latest version (2012 Q3), because in previous worked fine with  dymaically created and loaded datatemplate.

I Created a propertygrid with AutoGeneratingPropertyDefinition = true option.
In Autogeneratingpropertydefinition event I set the EditorTemplate property with 
datatemplate.
The datatemplate was generated string builder and loaded XamlReader.Load method.

When a I run the application i got following exception:
Unhandled exception ... Code 404
Category:ManagedRuntimeError
Message: System.Exception:Catastrophic Failure (Exception from HRESULLT:0x8000FFFF (E_UNEXPECTED))

I note again my test app in previous version its worked fine. 
 
Thanks!



      

9 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 19 Nov 2012, 09:56 AM
Hi,

Would it be possible for you to send us a repro project for this issue, so that we could debug it on our side and pinpoint its source? Thank you.

Kind regards,
Ivan Ivanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Robert
Top achievements
Rank 1
answered on 21 Nov 2012, 09:07 PM
Hi Ivan,
Thanks your help!
Here's my test usercontrol:
XAML code:
<UserControl x:Class="User.Test"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
	xmlns:local="clr-namespace:User"
    xmlns:mycombo="clr-namespace:User"
	mc:Ignorable="d"
			 x:Name="LayoutRoot"
	d:DesignHeight="300" d:DesignWidth="400">
	
			
	<Grid  Background="White">
		<Grid.RowDefinitions>
			<RowDefinition></RowDefinition>
			<RowDefinition></RowDefinition>
		</Grid.RowDefinitions>
        <telerik:RadPropertyGrid  Grid.Row="0" x:Name="partParamGrid" Width="500" MaxHeight="500" 
                                  AutoGeneratePropertyDefinitions="True"    
		                          ScrollViewer.VerticalScrollBarVisibility="Auto" 
                                  ScrollViewer.HorizontalScrollBarVisibility="Hidden" Item="{Binding Path=DctxData, Mode=TwoWay}" 
			        LabelColumnWidth="200" AutoGeneratingPropertyDefinition="partParamGrid_AutoGeneratingPropertyDefinition"  >
        </telerik:RadPropertyGrid>
       
	</Grid>
</UserControl>

and codebehind:

using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.ComponentModel;
using System.Text;
using System.Windows.Markup;
 
namespace User
{
    public partial class Test : UserControl
    {
        public Test()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(Test_Loaded);
        }
 
        public Data DctxData { get; set; }
 
        public  List<LookUpData> Look { get; set; }
   
        void Test_Loaded(object sender, RoutedEventArgs e)
        {
 
            DctxData = new Data() { A = 1, B = "Something text", C = true };
 
            Look = new List<LookUpData>();
            Look.Add(new LookUpData() { Key = 1, Value = "FirstValue" });
            Look.Add(new LookUpData() { Key = 2, Value = "SecondValue" });
 
            DataContext = this;
 
        }
 
        private void partParamGrid_AutoGeneratingPropertyDefinition(object sender, Telerik.Windows.Controls.Data.PropertyGrid.AutoGeneratingPropertyDefinitionEventArgs e)
        {
                if (e.PropertyDefinition.DisplayName=="A")
                e.PropertyDefinition.EditorTemplate = CreateComboTemplate("A");
                e.Cancel = false;
 
        }
 
     
            private DataTemplate CreateComboTemplate(string tag)
        {
            var sb = new StringBuilder();
            sb.Append("<DataTemplate ");
            sb.Append("xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' ");
            sb.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' ");
            sb.Append(" xmlns:propGrid='clr-namespace:Telerik.Windows.Controls.Data.PropertyGrid;assembly=Telerik.Windows.Controls.Data' ");
            sb.Append(" xmlns:telerik='http://schemas.telerik.com/2008/xaml/presentation'>");
 
            sb.Append("<Grid>");
            sb.Append("<telerik:RadComboBox x:Name=\"");
            sb.Append(tag);
            sb.Append("\" DisplayMemberPath=\"Value\" SelectedValuePath=\"Key\" ");
            sb.Append("SelectedValue=\"{Binding Path=");
            sb.Append(tag);
            sb.Append(",Mode=TwoWay}\" ");
            sb.Append(" propGrid:AutoBindBehavior.UpdateBindingOnElementLoaded=\"SelectedValue\" ");
            sb.Append(" ItemsSource=\"{Binding  Path=DataContext.Look, RelativeSource={RelativeSource FindAncestor,AncestorType=telerik:RadPropertyGrid,AncestorLevel=1}}\" >");
            sb.Append("</telerik:RadComboBox>");
            sb.Append("</Grid>");
            sb.Append("</DataTemplate>");
 
            DataTemplate dt = (DataTemplate)XamlReader.Load(sb.ToString());
 
            return dt;
        }
 
     
    }
 
 
 
 
    public class Data : INotifyPropertyChanged
    {
        private int a;
 
        public int A
        {
            get { return a; }
            set
            {
                a = value;
                NotifyChanged("A");
            }
        }
 
        private string b;
 
        public string B
        {
            get { return b; }
            set
            {
                b = value;
                NotifyChanged("B");
            }
        }
 
        private bool c;
 
        public bool C
        {
            get { return c; }
            set
            {
                c = value;
                NotifyChanged("C");
            }
        }
 
 
        public event PropertyChangedEventHandler PropertyChanged;
        public void NotifyChanged(string prop)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(prop));
            }
        }
 
    }
 
 
 
    public class LookUpData
    {
        public int Key { get; set; }
        public string Value { get; set; }
 
    }
 
 
 
}

Best regard,
Robert
0
Ivan Ivanov
Telerik team
answered on 27 Nov 2012, 09:54 AM
Hello,

We have managed to reproduce the issue. We will need some more time to research it. I will keep in touch with you to share any related updates.

Kind regards,
Ivan Ivanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Robert
Top achievements
Rank 1
answered on 29 Nov 2012, 02:55 PM
Hi Ivan,

I found one possible solutions, but it's just a workaround.
If i remove the <Grid> from template, it's working as needed.

I mention, i don't need the grid in this case, but what's happen if i need control more than one in a future.
Thank's your help.
Regards
Robert 
0
Ivan Ivanov
Telerik team
answered on 04 Dec 2012, 03:39 PM
Hi,

I am glad to hear that you have found a workaround. We will need some more time to find a global fix for the issue. I will come back and drop a line to inform you as soon as we are ready. Please, excuse us for this inconvenience.

Kind regards,
Ivan Ivanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Marcin Grabowski
Top achievements
Rank 1
answered on 06 Feb 2013, 03:01 PM
Hi.
Do you find any solution to this bug? We try to convert project to Q3 2012 from Q3 2011, now we must back to prevoius version. 
0
Ivan Ivanov
Telerik team
answered on 11 Feb 2013, 02:02 PM
Hi,

A fix will be available with Q1 2013 which is up to be released in about 10 days. Does this option work for you, or you have determined to use Q3 2013?

Greetings,
Ivan Ivanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Marcin Grabowski
Top achievements
Rank 1
answered on 12 Feb 2013, 12:35 PM
Hi.
If only "Q1 2013" dont have any breaking changes in TreeView or PropertyGrid, than we can wait for it.

For now we have made a workaround by modifying templates.

Thanks.
0
Ivan Ivanov
Telerik team
answered on 13 Feb 2013, 01:55 PM
Hi,

All of the known breaking changes for the new release will be listed in the release notes. Currently we can confirm one breaking change for RadPropertyGrid. We will do our best to provide all the needed guidelines to help you make this migration. 

Regards,
Ivan Ivanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
PropertyGrid
Asked by
Robert
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Robert
Top achievements
Rank 1
Marcin Grabowski
Top achievements
Rank 1
Share this question
or