null reference error for custom combobox template

I have made a custom control template to the combobox control that worked fine 
but after i changed the control to ComboBoxAdv i started to get this error 

Screenshot 2231528.png


the error happens the moment the mouse enters the Popup

<UserControl
    x:Class="MyDialogs.CustomComboBox.BootStrapComboBox"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:System="clr-namespace:System;assembly=mscorlib"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:MyDialogs.CustomComboBox"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:svg="http://sharpvectors.codeplex.com/runtime/"
    xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
    xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
    xmlns:syncfusionskin="clr-namespace:Syncfusion.SfSkinManager;assembly=Syncfusion.SfSkinManager.WPF"
    x:Name="BootStrapComboBoxControl"
    d:DesignHeight="30"
    d:DesignWidth="250"
    syncfusionskin:SfSkinManager.VisualStyle="Windows11Dark"
    mc:Ignorable="d">
    <Grid>
        <syncfusion:ComboBoxAdv
            Name="BootStrapCB"
            FontFamily="{Binding FontFamily, ElementName=BootStrapComboBoxControl}"
            FontSize="{Binding FontSize, ElementName=BootStrapComboBoxControl}"
            FontStretch="{Binding FontStretch, ElementName=BootStrapComboBoxControl}"
            IsEditable="False"
            IsTextSearchEnabled="False">
            <syncfusion:ComboBoxAdv.Template>
                <ControlTemplate TargetType="syncfusion:ComboBoxAdv">
                    <Border
                        x:Name="RootBorder"
                        Background="{TemplateBinding Background}"
                        CornerRadius="5"
                       >
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="15" />
                            </Grid.ColumnDefinitions>

                            <TextBlock
                                x:Name="PART_EditableTextBox"
                                Grid.Column="0"
                                Margin="5,1,2,1"
                                VerticalAlignment="Center"
                                FontFamily="{TemplateBinding FontFamily}"
                                FontSize="{TemplateBinding FontSize}"
                                IsHitTestVisible="False"
                                Text="{Binding Path=SelectedItem, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" />

                            <ToggleButton
                                Name="ToggleDropDown"
                                Grid.Column="1"
                                Margin="0,0,3,0"
                                ClickMode="Press"
                                Focusable="False"
                                IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                RenderTransformOrigin="0.5,0.5">

                                <ToggleButton.Template>
                                    <ControlTemplate TargetType="ToggleButton">
                                        <Grid>
                                            <Image x:Name="ToggleImage" Source="{svgc:SvgImage Source=/Resources/IconsSvg/downarrow_hlt.svg, AppName=FileDialog}" />
                                        </Grid>
                                        <ControlTemplate.Triggers>
                                            <Trigger Property="IsChecked" Value="True">
                                                <Setter TargetName="ToggleImage" Property="Source" Value="{svgc:SvgImage Source=/Resources/IconsSvg/downarrow_hlt.svg, AppName=FileDialog}" />
                                            </Trigger>
                                        </ControlTemplate.Triggers>
                                    </ControlTemplate>
                                </ToggleButton.Template>

                                <ToggleButton.RenderTransform>
                                    <RotateTransform x:Name="ToggleRotateTransform" Angle="180" />
                                </ToggleButton.RenderTransform>
                                <ToggleButton.Triggers>
                                    <EventTrigger RoutedEvent="ToggleButton.Checked">
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <DoubleAnimation
                                                    Storyboard.TargetName="ToggleRotateTransform"
                                                    Storyboard.TargetProperty="Angle"
                                                    To="0"
                                                    Duration="0:0:0.3" />
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </EventTrigger>
                                    <EventTrigger RoutedEvent="ToggleButton.Unchecked">
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <DoubleAnimation
                                                    Storyboard.TargetName="ToggleRotateTransform"
                                                    Storyboard.TargetProperty="Angle"
                                                    To="180"
                                                    Duration="0:0:0.3" />
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </EventTrigger>
                                </ToggleButton.Triggers>
                            </ToggleButton>
                            <Popup
                                Name="Popup"
                                AllowsTransparency="False"
                                Focusable="False"
                                IsOpen="{TemplateBinding IsDropDownOpen}"
                                Placement="Bottom"
                                PopupAnimation="Slide">
                                <Grid
                                    Name="DropDown"
                                    MinWidth="{TemplateBinding ActualWidth}"
                                    MaxHeight="{TemplateBinding MaxDropDownHeight}"
                                    Background="{TemplateBinding Background}"
                                    SnapsToDevicePixels="True">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="25" />
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>
                                    <Border
                                        Grid.Row="0"
                                        Background="#0FFFFFFF"
                                        BorderBrush="#0FFFFFFF"
                                        BorderThickness="1"
                                        CornerRadius="3">
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="21" />
                                                <ColumnDefinition Width="*" />

                                            </Grid.ColumnDefinitions>

                                            <Image
                                                Grid.Column="0"
                                                Width="17"
                                                Margin="2,0"
                                                Source="{svgc:SvgImage Source=/Resources/IconsSvg/VIEWZOOM.svg,
                                                                       AppName=FileDialog}" />
                                            <syncfusion:SfTextBoxExt
                                                x:Name="SearchBox"
                                                Grid.Column="1"
                                                Height="25"
                                                Margin="1,2,2,1"
                                                VerticalAlignment="Center"
                                                BorderBrush="{x:Null}"
                                                Text="{Binding SearchText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                TextAlignment="Left"
                                                Watermark="Search..." />
                                        </Grid>
                                    </Border>

                                    <Border
                                        x:Name="DropDownBorder"
                                        Grid.Row="1"
                                        Background="#0FFFFFFF"
                                        BorderBrush="#0FFFFFFF"
                                        BorderThickness="1" />


                                    <ScrollViewer
                                        Grid.Row="1"
                                        Margin="4,6,4,6"
                                        SnapsToDevicePixels="True">
                                        <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
                                    </ScrollViewer>
                                </Grid>
                            </Popup>
                        </Grid>
                    </Border>

                    <ControlTemplate.Triggers>
                        <Trigger Property="HasItems" Value="false">
                            <Setter TargetName="DropDownBorder" Property="MinHeight" Value="95" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="DimGray" />
                        </Trigger>
                        <Trigger Property="IsGrouping" Value="true">
                            <Setter Property="ScrollViewer.CanContentScroll" Value="false" />
                        </Trigger>
                        <Trigger SourceName="Popup" Property="Popup.AllowsTransparency" Value="true">
                            <Setter TargetName="DropDownBorder" Property="CornerRadius" Value="4" />
                            <Setter TargetName="DropDownBorder" Property="Margin" Value="0,2,0,0" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </syncfusion:ComboBoxAdv.Template>
            <syncfusion:ComboBoxAdv.Items>
               
                <System:String>Item 1</System:String>
                <System:String>Item 2</System:String>
                <System:String>Item 3</System:String>
            </syncfusion:ComboBoxAdv.Items>
        </syncfusion:ComboBoxAdv>

    </Grid>
</UserControl>


How to fix this error ?










4 Replies 1 reply marked as answer

BS Bhaskar Suresh Syncfusion Team January 25, 2024 05:50 PM UTC

Hi Ahmed,


We have confirmed the reported scenario is a defect and we will share the bug report for the reported scenario. We will provide the complete details to you on or before January 29, 2024.


Regards,

Bhaskar Suresh



BS Bhaskar Suresh Syncfusion Team January 29, 2024 02:49 PM UTC

Hi Ahmed,


We have confirmed the reported scenario is a defect and logged a report for the reported scenario, “System.NullReferenceException occurs when using custom ControlTemplate in ComboBoxAdv control”. We will fix this issue and include it in our NuGet release which is scheduled for 20th February 2024.


You can track the status of this defect using the following feedback link:

System.NullReferenceException occurs when using custom ControlTemplate in ComboBoxAdv control | Feedback Portal (syncfusion.com)


Please let us know if you need any further assistance.

Note: The provided feedback link is private, and you need to log in to view this feedback.


Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.”


Regards,

Bhaskar Suresh



BS Bhaskar Suresh Syncfusion Team February 21, 2024 06:51 AM UTC

Hi Ahmed,


Root cause:

When the custom ControlTemplate is used in the ComboBoxAdv control, the pop-up menu is null, so trying to access the pop-up property throws an exception.


We have included the fix for the reported issue “System.NullReferenceException occurs when using custom ControlTemplate in ComboBoxAdv control” in our Weekly NuGet release version 24.2.7 which is available for download (https://www.nuget.org/).


We thank you for your support and appreciate your patience in waiting for this update. Please get in touch with us if you require any further assistance.


Regards,

Bhaskar Suresh


Marked as answer

AM Ahmed moussa February 21, 2024 04:02 PM UTC

Thank you very much for responding to my issue .

so i have made this template because the search method using isEditing property of the combobox wasn't right for me

so i wanted to make a distinct textbox for searching /filtring the collection view 



this is the repo link using the wpf combobox if you would like to make a new control and adding it to the wpf library that would be great 

Screenshot (2).png


Loader.
Up arrow icon