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

Artificial fields and wpf

1 Answer 29 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michael
Top achievements
Rank 1
Michael asked on 30 Nov 2012, 06:21 AM

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

1 Answer, 1 is accepted

Sort by
0
Boris Georgiev
Telerik team
answered on 04 Dec 2012, 04:40 PM
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.
Tags
General Discussions
Asked by
Michael
Top achievements
Rank 1
Answers by
Boris Georgiev
Telerik team
Share this question
or