Artificial fields and wpf

2 posts, 0 answers
  1. Michael
    Michael avatar
    1 posts
    Member since:
    Feb 2012

    Posted 30 Nov 2012 Link to this post

    Hi there

    Is there any way to use artificiel fields with the wpf binding concept?

    I need to create a gui where a user can add user controls as he needs them. So I have a method which adds all the desired controls at runtime. Now I would like to use databinding from wpf like

    Binding binding = new Binding("SelectedItem.ArtField01");
    binding.ElementName = "AddressSearchGrid";
    binding.Mode = BindingMode.TwoWay;
    txtb.SetBinding(TextBlock.TextProperty, binding);

    Is there any way of doing this?

    Thank you, Mike Hachen

  2. Boris Georgiev
    Admin
    Boris Georgiev avatar
    190 posts

    Posted 04 Dec 2012 Link to this post

    Hello Michael,

    There are different approaches that could achieve that goal:

    1. If you know exactly what the new columns will be you can use wrapper on your classes and define your artificial fields as properties.

    2. If its not your case:
    a) Use Dictionary with Key - Artificial Field name, and value - Artificial Field value. Then you can easily bind Dictionary to control in WPF, only taking care when you save artificial fields in database.
    b) You should implement IValueConverter with artificial type as value, and artificial field as parameter, but it will be more difficult to implement in TwoWay binding mode.

    Do not hesitate to get back to us if you have any questions regarding the usage of Artificial Types.

    Greetings,
    Boris Georgiev
    the Telerik team
    Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
  3. DevCraft banner
Back to Top