<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>