我有这个ResourceDictionary:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cc="clr-namespace:CoCa.Views.CustomControls"
xmlns:vm="clr-namespace:CoCa.ViewModel">
<Style BasedOn="{StaticResource LabelStyle1}" TargetType="{x:Type Label}">
<Setter Property="Width" Value="130" />
<Setter Property="Foreground" Value="{StaticResource DetailsForegroundBrush}" />
</Style>
<Style BasedOn="{StaticResource SPanel}" TargetType="{x:Type StackPanel}" />
<Style BasedOn="{StaticResource InputParm}" TargetType="{x:Type cc:InputParameter}">
<Setter Property="Visibility" Value="Visible" />
<Setter Property="LBForeground" Value="{StaticResource DetailsForegroundBrush}" />
<Setter Property="TBForeground" Value="{StaticResource DetailsForegroundBrush}" />
<Setter Property="TBBackground" Value="{StaticResource DetailsControlsBackgroundBrush}" />
</Style>
<Style BasedOn="{StaticResource Radio}" TargetType="RadioButton">
<Setter Property="Foreground" Value="{StaticResource DetailsForegroundBrush}" />
</Style>
<Style BasedOn="{StaticResource ComboBoxStyle}" TargetType="{x:Type ComboBox}">
<Setter Property="Background" Value="{StaticResource DetailsControlsBackgroundBrush}" />
<Setter Property="Foreground" Value="{StaticResource DetailsForegroundBrush}" />
</Style>
<Style BasedOn="{StaticResource Items1}" TargetType="{x:Type ComboBoxItem}">
<Setter Property="Background" Value="{StaticResource DetailsControlsBackgroundBrush}" />
<Setter Property="Foreground" Value="{StaticResource DetailsForegroundBrush}" />
</Style>
<vm:IntToVisibility x:Key="intToVisibilityConverter" />
</ResourceDictionary>
我这样使用它:(删除了一些东西):
......
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<Border Margin="0" Style="{StaticResource DataGridDetailsBorder}">
<StackPanel
x:Name="MainPanel"
Margin="3,3,3,3"
Background="{StaticResource DetailsBackgroundBrush}"
DataContext="{Binding ElementName=DgSections, Path=SelectedItem, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
Orientation="Vertical">
<StackPanel.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="DataGridDetails.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</StackPanel.Resources>
<StackPanel x:Name="SectionType" Width="Auto">
<Label Content="Section type" />
<ComboBox
x:Name="SectionsComboBox"
....
SelectedValuePath="Key" />
</StackPanel>
<StackPanel x:Name="Material">
<StackPanel.Style>
....etc
整个
"Unable to cast object of type 'Microsoft.VisualStudio.DesignTools.Markup.DocumentModel.DocumentCompositeNode' to type 'System.Windows.ResourceDictionary'.
在我使用字典的两个地方都出现了错误(意为