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

Cannot set both DisplayMemberPath and ItemTemplate

1 Answer 368 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
kity
Top achievements
Rank 2
kity asked on 19 Aug 2014, 11:17 AM
I undestend that you some how with internal buisness logic set TextSearch.TextPath if developer set DisplayMemberPath value with ItemTemplate.
How you do it that with runtime code example?

I inherited your RadCombobox class

class EditComboBox : RadCombobox {
}

<Grid>
<controls:EditComboBox x:Name="ecbControl" telerik:TextSearch.TextPath="Description" />
</Grid>


How to dinamicly set
MyEditComboBox.TextSearch.TextPath="Description" ?

Here is my property

private static readonly DependencyProperty CurrentDisplayMemberPathProperty = DependencyProperty.RegisterAttached("CurrentDisplayMemberPath", typeof(string), typeof(EditComboBoxUserControl), new FrameworkPropertyMetadata(OnCurrentDisplayMemberPath));
       private static void OnCurrentDisplayMemberPath(DependencyObject d, DependencyPropertyChangedEventArgs e)
       {
           var view = (d as EditComboBoxUserControl);
           if (view == null)
               return;
           string value = (string)e.NewValue;
           view.CurrentDisplayMemberPath = value;           
       }
       [DefaultValue("")]
       [Localizability(LocalizationCategory.Text)]
       [Bindable(true)]
       public string CurrentDisplayMemberPath
       {
           get
           {
               return (string)GetValue(CurrentDisplayMemberPathProperty);
           }
           set
           {
               SetValue(CurrentDisplayMemberPathProperty, value);
               // Telerik.Windows.Controls.TextSearch.SetTextPath(this.ecbControl, value);
               //this.ecbControl.DisplayMemberPath = value;
           }
       }

Place your code is settary of dependancy property.

1 Answer, 1 is accepted

Sort by
0
kity
Top achievements
Rank 2
answered on 19 Aug 2014, 11:23 AM
May be if you undestend me, you will chosee some of two comment lines and then you will make some refactoring in control.
For example:

this.myComboBoxControl.NewDisplayMemberPath = value;
Tags
ComboBox
Asked by
kity
Top achievements
Rank 2
Answers by
kity
Top achievements
Rank 2
Share this question
or