我在从资源字典创建自己的模板时遇到问题。它显示异常:错误[行:0位置:0]。我找不到错误。这是我的来源:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:oktaCMS.Menu">
<!-- RIBBON PANEL TEMPLATE -->
<Style x:Key="RibbonPanelTemplate" TargetType="local:RibbonPanel">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:RibbonPanel">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="DefaultStates">
<VisualState x:Name="MouseOver" />
<VisualState x:Name="Normal"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border BorderBrush="#FFE2DFEF" BorderThickness="1" Margin="0" CornerRadius="4">
<Grid>
<Grid x:Name="ContentArea" Margin="0,0,0,20" Background="Transparent"/>
<Border BorderBrush="#FFE2DFEF" BorderThickness="0,1,0,0" Margin="0" VerticalAlignment="Bottom" Height="20" CornerRadius="0,0,4,4" Background="#FFD1CDE6">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</Grid>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
答案 0 :(得分:0)
如果使用XamlReader.Load()动态加载XAML,那么您可能需要使用程序集的全名(而不仅仅是clr名称空间)来限定“本地”名称空间。
E.g。改变这个:
xmlns:local="clr-namespace:oktaCMS.Menu"
这样的事情:
xmlns:local="clr-namespace:oktaCMS.Menu;assembly=MyAssemblyName"