提问人:sridhar patro 提问时间:10/27/2023 更新时间:10/27/2023 访问量:17
Xaml 异常:“在'System.Windows.Markup.StaticResourceHolder'上提供值引发了异常。 WPF的
Xaml exception: "Provide value on 'System.Windows.Markup.StaticResourceHolder' threw an exception." wpf
问:
我正在尝试设计一个用户控件,但是当我尝试构建时,它说“在'System.Windows.Markup.StaticResourceHolder'上提供值引发了异常。错误位于“BasedOn=”{StaticResource {x:Type controls:CustomButton}}“”
样式.xaml
<ResourceDictionary>
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:CustomControl">
<Style x:Key="PrimaryButtonStyle" TargetType="controls:CustomButton" BasedOn="{StaticResource {x:Type controls:CustomButton}}">
<Setter Property="Width" Value="182"/>
<Setter Property="Height" Value="40"/>
</Style>
</ResourceDictionary>
MyUserControl.xaml
<UserControl x:Class="Titan.SystrayPopupPlugin.Audio.Views.GenericAudioOsdView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" xmlns:controls="clr-namespace:CustomControl">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,24,0,0">
<controls:CustomButton Style="{DynamicResource SecondaryButtonStyle}"/>
</StackPanel>
</StackPanel>
</Grid>
</UserControl>
答: 暂无答案
评论