Exception 'Cannot Find Type' when using control from control library that references control from another library
I am using a DatePicker from the WPFToolkit library in a UserControl I have defined in a ControlLibrary.
If I use my UserControl from another application I get an ApplicationException: "Cannot find type 'Microsoft.Windows.Controls.DatePicker'. The assembly used when compiling might be different than that used when loading and the type is missing."
I am able to avoid this exception if I add an assembly reference to WPFToolkit library from the Application that is referencing my UserControl. Is there a way for me to do this without having to reference the WPFToolkit assembly in my Application?
Here is the xaml for my UserControl:
<UserControl x:Class="View.DateRangeView"
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:toolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
mc:Ignorable="d"
d:DesignHeight="50" d:DesignWidth="300">
<UserControl.Resources>
<ResourceDictionary Source="/ReuxablesLegacy;component/candy.xaml" />
</UserControl.Resources>
<Grid VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" SharedSizeGroup="enable" />
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" >
<toolkit:DatePicker Margin="3" SelectedDate="{Binding Path=LowRange}" Width="100" />
<TextBlock Text=" To " Margin="3" VerticalAlignment="Center" />
<toolkit:DatePicker Margin="3" SelectedDate="{Binding Path=HighRange}" Width="100" />
</StackPanel>
<CheckBox Grid.Column="1" Content="Enab开发者_如何学Gole" Margin="3" VerticalAlignment="Center" IsChecked="{Binding Path=Enabled}" />
</Grid>
</UserControl>
you have to add a reference to both your assembly and the 3rd party assembly to the application.
精彩评论