Hello,
I am using silverlight XamComoEditor. In my scenario I need to bind string collection to the comboeditor. I have enabled editing. I got an exception when I entered a new item since the new String object was not getting created. I found a workaround for that.
My problem is when I select a value from the dropdown list, nothing gets selected i.e the selection is not retained. When I set the 'IsEditable' property to false, the item gets selected. But when I set it to True, the selection stops working. I guess I must be missing somthing.
Can anyone help me to make this work...
View is Like this:
<
Code Behind is like this:
public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); ViewModel vm = new ViewModel(); this.DataContext = vm; }
private void XamComboEditor_DataObjectRequested(object sender, Infragistics.HandleableObjectGenerationEventArgs e) {
List<UIElement> items = new List<UIElement>();
GetChildren(((XamComboEditor)sender), typeof(TextBox), ref items);
TextBox txtbox = (TextBox)items[0];
String str = new String(txtbox.Text.ToCharArray());
e.NewObject = str; e.Handled = true; }
private void GetChildren(UIElement parent, Type targetType, ref List<UIElement> children) { int count = VisualTreeHelper.GetChildrenCount(parent); if (count > 0) { for (int i = 0; i < count; i++) { UIElement child = (UIElement)VisualTreeHelper.GetChild(parent, i); if (child.GetType() == targetType) { children.Add(child); break; } GetChildren(child, targetType, ref children); } } } }
ViewModel is like this:
public class ViewModel { private ObservableCollection<string> stringCollection = new ObservableCollection<string>();
public ObservableCollection<string> StringCollection { get { return stringCollection; } set { stringCollection = value; } }
public ViewModel() { stringCollection.Add("test1"); stringCollection.Add("test2"); stringCollection.Add("test3"); stringCollection.Add("test4"); stringCollection.Add("test4"); stringCollection.Add("test6"); }
}
Thanks,
Shruti
I'll try to create a new solution if the problem still exists I will send you the solution.
Thanks.
Meisam.
Hi,
I was not able to reproduce the behavior you described. What's the version of XamComboEditor you are using?
In a nutshell this is a snippet of the code that I'm using
<ig:XamComboEditor CustomValueEnteredAction="Add" ItemsSource="{Binding items,Mode=TwoWay}" SelectedItem="{Binding selectedItem,Mode=TwoWay}" DisplayMemberPath="Name" HorizontalAlignment="Left" VerticalAlignment="Center" Width="250" Height="30"> </ig:XamComboEditor>
when you start playing with items in the combo editor, you will see replicated items in the combobox.
Any remedy for this?
this really sounds weird. Could you please provide some details on your scenario as well as which version of the controls you are using?
Regards,
Could you please let me know how you fixed your problem?
I have a weird situation here. When I select an item from the combobox a new item is generated and added to the list of items!!!