我在Ribbon控件库中遇到错误,当这个错误在使用功能区控件的类中的new()方法中断时。
类型' System.TypeInitializationException'的例外情况发生在WpfPluggableApp.exe中但未在用户代码中处理
其他信息:' Microsoft.Windows.Controls.Ribbon.RibbonWindow'的类型初始值设定项。抛出异常。
但是当我继续时,我得到了这个错误
未处理的类型' System.Windows.Markup.XamlParseException'发生在PresentationFramework.dll
中其他信息:'在类型' WpfPluggableApp.MainWindow'上调用构造函数。匹配指定的绑定约束引发异常。'行号' 3'和行位置' 5'。
在MainWindow.Xaml的第3行,我无法看到任何影响它的内容:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<DockPanel>
<Menu Name="mnu" DockPanel.Dock="Top">
</Menu>
<TabControl ItemsSource="{Binding Path=ViewModels}">
<TabControl.ItemContainerStyle>
<Style TargetType="{x:Type TabItem}">
<Setter Property="IsSelected" Value="{Binding Path=isSelected,Mode=TwoWay}"/>
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<DockPanel MinWidth="120">
<Button
Command="{Binding Path=CloseCommand}"
Content="X"
Cursor="Hand"
DockPanel.Dock="Right"
Focusable="False"
FontFamily="Courier"
FontSize="9"
FontWeight="Bold"
Margin="0,1,0,0"
Padding="0"
VerticalContentAlignment="Center"
Width="16" Height="16"
IsTabStop="False"
/>
<ContentPresenter Margin="10"
Content="{Binding Path=DisplayName}"
VerticalAlignment="Center"
/>
</DockPanel>
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="Content" Value="{Binding}" />
</Style>
</TabControl.ItemContainerStyle>
</TabControl>
</DockPanel>
以下是功能区的xaml:
<ribbon:RibbonWindow x:Class="MainRibbonWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
Title="MainRibbonWindow"
x:Name="MainRibbonWindow"
WindowState="Maximized" MinHeight="480" MinWidth="640">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ribbon:Ribbon x:Name="Ribbon">
</ribbon:Ribbon>
<TabControl Grid.Row="1" ItemsSource="{Binding Path=ViewModels}">
<TabControl.ItemContainerStyle>
<Style TargetType="{x:Type TabItem}">
<Setter Property="IsSelected" Value="{Binding Path=isSelected,Mode=TwoWay}"/>
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<DockPanel MinWidth="120">
<Button
Command="{Binding Path=CloseCommand}"
Content="X"
Cursor="Hand"
DockPanel.Dock="Right"
Focusable="False"
FontFamily="Courier"
FontSize="9"
FontWeight="Bold"
Margin="0,1,0,0"
Padding="0"
VerticalContentAlignment="Center"
Width="16" Height="16"
IsTabStop="False"
/>
<ContentPresenter
Content="{Binding Path=DisplayName}"
VerticalAlignment="Center"
/>
</DockPanel>
</DataTemplate>
</Setter.Value>
</Setter>
<!--<Setter Property="Content" Value="{Binding}" />-->
</Style>
</TabControl.ItemContainerStyle>
</TabControl>
</Grid>
可能需要一双新眼睛来看它!如果你能看到问题,请告诉我。
谢谢, 萨姆
----------------------- EDIT ----------------------- ------------------
问题已经解决,我引用了错误的类库。
答案 0 :(得分:0)
抱歉,我已经对它进行了分类。有错误版本的类库导致错误。