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

5 posts, 0 answers
  1. Hans
    Hans avatar
    36 posts
    Member since:
    Nov 2017

    Posted 11 Jul Link to this post

    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

     

     

     

  2. Martin Ivanov
    Admin
    Martin Ivanov avatar
    2194 posts

    Posted 16 Jul Link to this post

    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.
  3. Martin Ivanov
    Admin
    Martin Ivanov avatar
    2194 posts

    Posted 16 Jul Link to this post

    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.
  4. Hans
    Hans avatar
    36 posts
    Member since:
    Nov 2017

    Posted 16 Jul Link to this post

    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

  5. Martin Ivanov
    Admin
    Martin Ivanov avatar
    2194 posts

    Posted 16 Jul Link to this post

    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.
Back to Top