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

Set the AutoCompleteMode in a style generates an error in my XAML

4 Answers 28 Views
MultiColumnComboBox
This is a migrated thread and some comments may be shown as answers.
Hans
Top achievements
Rank 1
Veteran
Hans asked on 11 Jul 2019, 06:29 AM

Hi,

I have following style applied for all my RadMultiColumnComboBox controls (in the app.xaml):

<!--Telerik default DefaultTelerikRadMultiColumnComboBoxStyle-->
<Style x:Key="DefaultTelerikRadMultiColumnComboBoxStyle" TargetType="telerik:RadMultiColumnComboBox" BasedOn="{StaticResource RadMultiColumnComboBoxStyle}">
    <!--<Setter Property="SelectionMode" Value="Single"/>-->
    <Setter Property="AutoCompleteMode" Value="Search"/>
    <Setter Property="FontFamily" Value="{StaticResource DefaultFont}"/>
    <Setter Property="FontSize" Value="{StaticResource DefaultFontSize}"/>
    <Setter Property="FontWeight" Value="{StaticResource DefaultFontWeight}"/>
    <Setter Property="MinHeight" Value="{StaticResource DefaultMinimumHeight}"/>
    <Setter Property="KeepDropDownOpen" Value="False"/>
    <Setter Property="CloseDropDownAfterSelectionInput" Value="True"/>
    <Setter Property="SelectionBoxesVisibility" Value="Visible"/>
 
    <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ErrorTemplate}"/>
 
    <Style.Triggers>
        <Trigger Property="IsEnabled" Value="True">
            <Setter Property="Background" Value="{StaticResource DefaultTextBoxBackgroundColor}"/>
        </Trigger>
        <Trigger Property="IsEnabled" Value="False">
            <Setter Property="Background" Value="Red"/>
        </Trigger>
        <Trigger Property="IsFocused"  Value="True">
            <Setter Property="Background"  Value="{StaticResource DefaultTextBoxIsFocusedBackgroundColor}"/>
        </Trigger>
    </Style.Triggers>
</Style>
<Style TargetType="{x:Type telerik:RadMultiColumnComboBox}" BasedOn="{StaticResource DefaultTelerikRadMultiColumnComboBoxStyle}"/>

 

With this style applied, I get this error in my XAML files (see attached file): The element "[RadMultiColumnComboBox]" could not be displayed because of a problem with System.Windows.StaticResourceExtension: CollectionView must have value. Parameter name: collectionView.

The error is provoced by the setter of the AutoCompleteMode.  The error disappears when this setter is deleted.

Setting the AutoCompleteMode directly on a RadMultiColumnComboBox (with the style applied) does not cause any problems.

Any ideas ??

Regards,
Hans

 

 

 

4 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 16 Jul 2019, 06:29 AM
Hello Hans,

I will try to replicate the issue and get back here when I got more information.

Regards,
Martin Ivanov
Progress TelerikWant to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Martin Ivanov
Telerik team
answered on 16 Jul 2019, 02:10 PM
Hello Hans,

I've tested this on my side and I can confirm that, this is an issue with the RadMultiColumnComboBox control. I logged it in our feedback portal where you can track its status, and also updated your Telerik points.

To work this around set the AutoCompleteMode directly on the control, as you are already doing. I hope this helps.

Regards,
Martin Ivanov
Progress TelerikWant to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Hans
Top achievements
Rank 1
Veteran
answered on 16 Jul 2019, 02:17 PM

Hello Martin,

thanks for the information. I hope the issue will be resolved in the next release, I have a lot of RAdMultiColumnComboBox controls ;-)

Regards,
Hans

0
Martin Ivanov
Telerik team
answered on 16 Jul 2019, 02:42 PM
Hello Hans,

If you want to keep using the Style, you can create an attached property that sets the AutoCompleteMode and use it in the Style. Here is an example in code:
public static class MccbUtilities
{
    private static Dictionary<ItemsSourceProvider, RadMultiColumnComboBox> itemsSourceProviderToMccb = new Dictionary<ItemsSourceProvider, RadMultiColumnComboBox>();
 
    public static SearchAutoCompleteMode GetAutoCompleteMode(DependencyObject obj)
    {
        return (SearchAutoCompleteMode)obj.GetValue(AutoCompleteModeProperty);
    }
 
    public static void SetAutoCompleteMode(DependencyObject obj, SearchAutoCompleteMode value)
    {
        obj.SetValue(AutoCompleteModeProperty, value);
    }
             
    public static readonly DependencyProperty AutoCompleteModeProperty =
        DependencyProperty.RegisterAttached("AutoCompleteMode", typeof(SearchAutoCompleteMode), typeof(MccbUtilities), new PropertyMetadata(SearchAutoCompleteMode.Append, OnAutoCompleteModeChanged));
 
    private static void OnAutoCompleteModeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        var mccb = (RadMultiColumnComboBox)d;
        if (mccb.ItemsSourceProvider.CollectionView == null)
        {
            itemsSourceProviderToMccb[mccb.ItemsSourceProvider] = mccb;
            mccb.ItemsSourceProvider.PropertyChanged += ItemsSourceProvider_PropertyChanged;
        }
        else
        {
            mccb.AutoCompleteMode = (SearchAutoCompleteMode)e.NewValue;
        }
         
    }
 
    private static void ItemsSourceProvider_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
    {
        var provider = (ItemsSourceProvider)sender;
        if (e.PropertyName == "CollectionView")
        {
            var mccb = itemsSourceProviderToMccb[provider];
            mccb.AutoCompleteMode = GetAutoCompleteMode(mccb);
 
            provider.PropertyChanged -= ItemsSourceProvider_PropertyChanged;
        }
    }
}

<Style TargetType="telerik:RadMultiColumnComboBox">           
    <Setter Property="local:MccbUtilities.AutoCompleteMode" Value="Search"/>           
</Style>

Regards,
Martin Ivanov
Progress TelerikWant to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
MultiColumnComboBox
Asked by
Hans
Top achievements
Rank 1
Veteran
Answers by
Martin Ivanov
Telerik team
Hans
Top achievements
Rank 1
Veteran
Share this question
or