Hi, I'm developing a user control called SearchBox, that will act as a replacer for ComboBox for multiple records, as the performance in ComboBox is low for this scenario, but I'm having a big binding problem.
I have a base control with a DependencyProperty called SelectedItem, and my SearchControl shows that control so that the user can select the record. The SearchControl also has a DependencyProperty called SelectedItem on it, and it is being updated when the user selects something on the base control, but the UI, wich has the SearchControl, is not being updated. I used a null converter so that I could see if the property was updating, but it's not. Below is some of the code: This is the UI:
<NectarControles:MaskedSearchControl x:Name="teste"
Grid.Row="0" Grid.Column="1"
Height="21"
ItemsSource="{Binding C001_Lista}"
DisplayMember="C001_Codigo"
Custom:CustomizadorTextBox.CodigoCampo="C001_Codigo"
ViewType="{x:Type C001:C001_Search}"
ViewModelType="{x:Type C001_ViewModel:C001_ViewModel}"
SelectedItem="{Binding Path=Instancia.C001_Holding, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource DebuggingConverter}}">
</NectarControles:MaskedSearchControl>
This is the relevante part of the SearchControl:
Binding selectedItemBinding = new Binding("SelectedItem");
selectedItemBinding.Source = this.SearchControlBase;
selectedItemBinding.Mode = BindingMode.TwoWay;
selectedItemBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
this.SetBinding(SelectedItemProperty, selectedItemBinding);
...
public System.Data.Objects.DataClasses.IEntityWithKey SelectedItem
{
get
{
return (System.Data.Objects.DataClasses.IEntityWithKey)GetValue(SelectedItemProperty);
}
set
{
SetValue(SelectedItemProperty, value);
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("SelectedItem"));
}
}
Please someone help me...