Я нашел решение для моей проблемы.Вот код:
<UserControl x:Class="CustomComboBox.ucComboBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:CustomComboBox"
Loaded="UserControl_Loaded"
mc:Ignorable="d"
d:DesignHeight="50" d:DesignWidth="300">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="0">User Control</Label>
<ComboBox Name="cmb" Grid.Row="0" Grid.Column="1" >
</ComboBox>
</Grid>
public partial class ucComboBox : UserControl
{
public ucComboBox()
{
InitializeComponent();
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
cmb.ItemsSource = ValueList;
}
public List<ComboBoxItem> ValueList
{
get { return (List<ComboBoxItem>)GetValue(ValueListProperty); }
set { SetValue(ValueListProperty, value); }
}
// Using a DependencyProperty as the backing store for ValueList. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ValueListProperty =
DependencyProperty.Register("ValueList", typeof(List<ComboBoxItem>), typeof(ucComboBox), new FrameworkPropertyMetadata(new List<ComboBoxItem>(), FrameworkPropertyMetadataOptions.AffectsRender, new PropertyChangedCallback(Target)));
private static void Target(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
}
}
<Window x:Class="CustomComboBox.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:CustomComboBox"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<ComboBox Grid.Row="0" Grid.Column="1">
<ComboBoxItem>Male</ComboBoxItem>
<ComboBoxItem>Female</ComboBoxItem>
</ComboBox>
<local:ucComboBox x:Name="cmb" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" >
<local:ucComboBox.ValueList>
<ComboBoxItem>All</ComboBoxItem>
<ComboBoxItem>Male</ComboBoxItem>
<ComboBoxItem>Female</ComboBoxItem>
</local:ucComboBox.ValueList>
</local:ucComboBox>
</Grid>