Custom Editor in AutoGeneratingPropertyDefinition Event

10 posts, 0 answers
  1. Robert
    Robert avatar
    3 posts
    Member since:
    Nov 2012

    Posted 16 Nov 2012 Link to this post

    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!



          
  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 19 Nov 2012 Link to this post

    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.

  3. DevCraft banner
  4. Robert
    Robert avatar
    3 posts
    Member since:
    Nov 2012

    Posted 21 Nov 2012 Link to this post

    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 { getset; }
     
            public  List<LookUpData> Look { getset; }
       
            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(thisnew PropertyChangedEventArgs(prop));
                }
            }
     
        }
     
     
     
        public class LookUpData
        {
            public int Key { getset; }
            public string Value { getset; }
     
        }
     
     
     
    }

    Best regard,
    Robert
  5. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 27 Nov 2012 Link to this post

    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.

  6. Robert
    Robert avatar
    3 posts
    Member since:
    Nov 2012

    Posted 29 Nov 2012 Link to this post

    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 
  7. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 04 Dec 2012 Link to this post

    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.

  8. Marcin Grabowski
    Marcin Grabowski avatar
    20 posts
    Member since:
    Nov 2009

    Posted 06 Feb 2013 Link to this post

    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. 
  9. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 11 Feb 2013 Link to this post

    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.

  10. Marcin Grabowski
    Marcin Grabowski avatar
    20 posts
    Member since:
    Nov 2009

    Posted 12 Feb 2013 Link to this post

    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.
  11. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 13 Feb 2013 Link to this post

    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.

Back to Top
DevCraft banner