Tôi có một bộ kiểu rất đơn giản mà tôi đang sử dụng trong một vài ứng dụng WPF khác nhau. Tôi có kiểu này được lưu trữ trong một tệp Xaml trong một dự án chung, sau đó được thêm bằng cách hợp nhất vào Resources
trong App.xaml
trong mỗi dự án.Kiểu TargetType gây ra XamlParseException khi không được đính kèm với trình gỡ lỗi
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity">
<Style TargetType="dxe:ComboBoxEdit">
<Setter Property="AutoComplete" Value="True" />
<Setter Property="IncrementalFiltering" Value="True" />
<Setter Property="ImmediatePopup" Value="True" />
<Setter Property="IsTextEditable" Value="True" />
<Setter Property="ClearSelectionOnBackspace" Value="True" />
</Style>
<Style TargetType="dxe:ComboBoxEditSettings">
<Setter Property="AutoComplete" Value="True" />
<Setter Property="IncrementalFiltering" Value="True" />
<Setter Property="ImmediatePopup" Value="True" />
<Setter Property="IsTextEditable" Value="True" />
</Style>
</ResourceDictionary>
Thật không may, một cái gì đó về vấn đề này đang gây ra một XamlParseException
về TargetType
bất động sản, nhưng chỉ khi không gắn liền với debugger. Nếu tôi khởi động ứng dụng trong trình gỡ lỗi, mọi thứ đều ổn. Nếu tôi "Start Without Debugging", tôi có được điều này như App.xaml
đang được nạp:
System.Windows.Markup.XamlParseException: 'Failed to create a 'TargetType' from the text 'dxe:ComboBoxEdit'.' Line number '5' and line position '12'. ---> System.Xaml.XamlParseException: Type reference cannot find type named '{http://schemas.devexpress.com/winfx/2008/xaml/editors}ComboBoxEdit'.
at MS.Internal.Xaml.Context.ObjectWriterContext.ServiceProvider_Resolve(String qName)
at MS.Internal.Xaml.ServiceProviderContext.System.Windows.Markup.IXamlTypeResolver.Resolve(String qName)
at System.Xaml.Replacements.TypeTypeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateObjectWithTypeConverter(ServiceProviderContext serviceContext, XamlValueConverter`1 ts, Object value)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateFromValue(ServiceProviderContext serviceContext, XamlValueConverter`1 ts, Object value, XamlMember property)
at System.Xaml.XamlObjectWriter.Logic_CreateFromValue(ObjectWriterContext ctx, XamlValueConverter`1 typeConverter, Object value, XamlMember property, String targetName, IAddLineInfo lineInfo)
--- End of inner exception stack trace ---
at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at Shell.App.InitializeComponent() in c:\DevProjects\CoreApplication\Shell\App.xaml:line 1
at Shell.App.Main() in C:\DevProjects\CoreApplication\Shell\obj\x86\Debug\App.g.cs:line 0
Nếu tôi nhận xét ra cả Style
nút, sau đó mọi thứ hoạt động một cách chính xác. Ý tưởng nào?
Còn cú pháp 'TargetType =" {x: Type} "thì sao? –
Jay
@Jay: Không may là kết quả tương tự. –
Bạn có đặt các kiểu điều khiển tùy chỉnh của mình bên trong Chủ đề/Generic.xaml không? –