Get the value represented by PropertyGridField

6 posts, 0 answers
  1. Akram
    Akram avatar
    45 posts
    Member since:
    Dec 2012

    Posted 13 Dec 2012 Link to this post

    Hi
    Is there is a way to get the  value represented by PropertyGridField.

    Thanks,
    Akram
  2. Akram
    Akram avatar
    45 posts
    Member since:
    Dec 2012

    Posted 14 Dec 2012 Link to this post

    I found the solution by refection, 
    there is an internal property called CurrentContextPropertyValue inside the field, call it by reflection and you will get the value associated to that field.

    This is a sample code

    var ss = typeof(PropertyGridField).GetProperty("CurrentContextPropertyValue", (BindingFlags)0xfff).GetValue(field,null);

    Thanks,
    Akram
  3. UI for WPF is Visual Studio 2017 Ready
  4. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 14 Dec 2012 Link to this post

    Hello,

    Reflecting member that are not in the API is not a good practice. They are defined for internal use only and sometimes they might behave inconsistently in accordance to you expectations. 

    Greetings,
    Ivan Ivanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  5. Akram
    Akram avatar
    45 posts
    Member since:
    Dec 2012

    Posted 14 Dec 2012 Link to this post

    Ok, then please help me to find a safe way

    Thanks,
    Akram
  6. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 14 Dec 2012 Link to this post

    Hi,

    Fields are ContentControls. You can get their content, cast it to the expected type (i.e TextBox) and retrieve the current value by reading the respective property (TextBox.Text).

    Greetings,
    Ivan Ivanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  7. Akram
    Akram avatar
    45 posts
    Member since:
    Dec 2012

    Posted 14 Dec 2012 Link to this post

    Hi
    This can't be a perfect solution because i need the object to have the same reference to the origin one,
    Also, Not all cases can be  cased into TextBox, some is DateTimePicker, some is Numeric .

    Why not to provide a public property that do the same as the CurrentContextPropertyValue 

    Thanks,
    Akram
Back to Top
UI for WPF is Visual Studio 2017 Ready