we are using a telerik autocomplete box. Now, the code pasted below works on ALL computers except my surface pro 2. any reason you know of?
Interestingly, this used to work on my machine because I approved the developers update.
The problem is that even though the "SelectedServices" is being populated, the control on the UI is not getting it. and the control on the UI is not sending down the data either.
I can post any more info you guys need to help trace this. But again, code works on all computers except surface pro 2 with windows 8.1
<telerik:RadAutoCompleteBox x:Name="ServicesAutoCompleteBox"
Grid.Row="1"
Grid.Column="1"
HorizontalAlignment="Stretch"
AutoCompleteMode="Suggest"
DisplayMemberPath="ItemText"
FilteringBehavior="{StaticResource CustomFilteringBehavior}"
GotFocus="UIElement_OnGotFocus"
ItemsSource="{Binding ServiceItems}"
SelectedItems="{Binding SelectedServices,
UpdateSourceTrigger=PropertyChanged}"
SelectionMode="Multiple"
TextSearchMode="StartsWith"
TextSearchPath="ItemText"
WatermarkContent="Type or click to add Services...."
>
<telerik:RadAutoCompleteBox.BoxesItemTemplate>
<DataTemplate DataType="lookups:ItemLookupViewModel">
<WrapPanel Width="{Binding ElementName=ServicesAutoCompleteBox,
Path=ActualWidth}"
Margin="0 0 -30 0"
>
<TextBlock Padding="0 0 30 0"
Text="{Binding ItemText}"
TextWrapping="Wrap"
/>
</WrapPanel>
</DataTemplate>
</telerik:RadAutoCompleteBox.BoxesItemTemplate>
</telerik:RadAutoCompleteBox>
#region Methods
private void PopulatAutoBoxCollection(object sender)
{
var autoComplete = (RadAutoCompleteBox) sender;
autoComplete.Populate(autoComplete.SearchText);
}
#endregion
#region Event Handlers
private void UIElement_OnGotFocus(object sender, RoutedEventArgs e)
{
PopulatAutoBoxCollection(sender);
}
#endregion
public class CustomFilteringBehavior : FilteringBehavior
{
#region Methods
public override IEnumerable<object> FindMatchingItems(string searchText, System.Collections.IList items, IEnumerable<object> escapedItems, string textSearchPath, TextSearchMode textSearchMode)
{
if (string.IsNullOrEmpty(searchText))
{
return items.OfType<object>().Where(x => !escapedItems.Contains(x));
}
return base.FindMatchingItems(searchText, items, escapedItems, textSearchPath, textSearchMode);
}
#endregion
}
public ObservableCollection<ItemLookupViewModel> ServiceItems { get; private set; }
public ObservableCollection<ItemLookupViewModel> SelectedServices { get; set; }
SelectedServices = new ObservableCollection<ItemLookupViewModel>();
SelectedServices.CollectionChanged += SelectedServicesCollectionChanged;
// Set Services.-- this copies data from the model into the bound control
foreach (var serviceItem in _solicitation.Services)
foreach (var serviceItemVm in ServiceItems)
if (serviceItem.Service.RefItemId == serviceItemVm.ItemId)
SelectedServices.Add(serviceItemVm);
private void SelectedServicesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
IndicateSolicitationChanged();
if (e.NewItems != null && e.NewItems.Count != 0)
{
// foreach (ItemLookupViewModel siVm in e.NewItems)
// {
// }
}
if (e.OldItems != null && e.OldItems.Count != 0)
{
foreach (ItemLookupViewModel siVm in e.OldItems)
siVm.Cleanup();
}
}
Interestingly, this used to work on my machine because I approved the developers update.
The problem is that even though the "SelectedServices" is being populated, the control on the UI is not getting it. and the control on the UI is not sending down the data either.
I can post any more info you guys need to help trace this. But again, code works on all computers except surface pro 2 with windows 8.1
<telerik:RadAutoCompleteBox x:Name="ServicesAutoCompleteBox"
Grid.Row="1"
Grid.Column="1"
HorizontalAlignment="Stretch"
AutoCompleteMode="Suggest"
DisplayMemberPath="ItemText"
FilteringBehavior="{StaticResource CustomFilteringBehavior}"
GotFocus="UIElement_OnGotFocus"
ItemsSource="{Binding ServiceItems}"
SelectedItems="{Binding SelectedServices,
UpdateSourceTrigger=PropertyChanged}"
SelectionMode="Multiple"
TextSearchMode="StartsWith"
TextSearchPath="ItemText"
WatermarkContent="Type or click to add Services...."
>
<telerik:RadAutoCompleteBox.BoxesItemTemplate>
<DataTemplate DataType="lookups:ItemLookupViewModel">
<WrapPanel Width="{Binding ElementName=ServicesAutoCompleteBox,
Path=ActualWidth}"
Margin="0 0 -30 0"
>
<TextBlock Padding="0 0 30 0"
Text="{Binding ItemText}"
TextWrapping="Wrap"
/>
</WrapPanel>
</DataTemplate>
</telerik:RadAutoCompleteBox.BoxesItemTemplate>
</telerik:RadAutoCompleteBox>
#region Methods
private void PopulatAutoBoxCollection(object sender)
{
var autoComplete = (RadAutoCompleteBox) sender;
autoComplete.Populate(autoComplete.SearchText);
}
#endregion
#region Event Handlers
private void UIElement_OnGotFocus(object sender, RoutedEventArgs e)
{
PopulatAutoBoxCollection(sender);
}
#endregion
public class CustomFilteringBehavior : FilteringBehavior
{
#region Methods
public override IEnumerable<object> FindMatchingItems(string searchText, System.Collections.IList items, IEnumerable<object> escapedItems, string textSearchPath, TextSearchMode textSearchMode)
{
if (string.IsNullOrEmpty(searchText))
{
return items.OfType<object>().Where(x => !escapedItems.Contains(x));
}
return base.FindMatchingItems(searchText, items, escapedItems, textSearchPath, textSearchMode);
}
#endregion
}
public ObservableCollection<ItemLookupViewModel> ServiceItems { get; private set; }
public ObservableCollection<ItemLookupViewModel> SelectedServices { get; set; }
SelectedServices = new ObservableCollection<ItemLookupViewModel>();
SelectedServices.CollectionChanged += SelectedServicesCollectionChanged;
// Set Services.-- this copies data from the model into the bound control
foreach (var serviceItem in _solicitation.Services)
foreach (var serviceItemVm in ServiceItems)
if (serviceItem.Service.RefItemId == serviceItemVm.ItemId)
SelectedServices.Add(serviceItemVm);
private void SelectedServicesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
IndicateSolicitationChanged();
if (e.NewItems != null && e.NewItems.Count != 0)
{
// foreach (ItemLookupViewModel siVm in e.NewItems)
// {
// }
}
if (e.OldItems != null && e.OldItems.Count != 0)
{
foreach (ItemLookupViewModel siVm in e.OldItems)
siVm.Cleanup();
}
}