WPF 样式的一个问题

code_long code_long 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
无法将类型为“MS.Internal.NamedObject”的对象强制转换为类型“System.Windows.FrameworkTemplate”。
在 System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
问题应该是出现在
<Setter Property="Template" Value="{StaticResource WindowControlTemplate}"></Setter>
Template某一个属性值不对 麻烦帮忙看一下


<Style x:Key="ChildWinStyle" TargetType="{x:Type Window}">
<Setter Property="OverridesDefaultStyle" Value="True"></Setter>
<Setter Property="ResizeMode" Value="CanResizeWithGrip"></Setter>
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="FontFamily" Value="Arial"></Setter>
<Setter Property="Window.BorderBrush" Value="#FF4C95BA"></Setter>
<Setter Property="Window.BorderThickness" Value="0"></Setter>
<Setter Property="Template" Value="{StaticResource WindowControlTemplate}"></Setter>
<!--Set Label and GroupBox foreground color-->
<Style.Resources>
<Style TargetType="{x:Type Label}" >
<Setter Property="Foreground" Value="{DynamicResource FontForeground}"></Setter>
<Setter Property="VerticalContentAlignment" Value="Center"></Setter>
</Style>
<Style x:Key="lbBaseStyle" TargetType="{x:Type Label}">
<Setter Property="Height" Value="22"></Setter>
</Style>
<Style x:Key="tabControlStyle">
<Style.Resources>
<Style TargetType="{x:Type Label}" >
<Setter Property="Foreground" Value="#000000"></Setter>
<Setter Property="VerticalContentAlignment" Value="Center"></Setter>
</Style>
</Style.Resources>
</Style>
</Style.Resources>
</Style>
<ControlTemplate x:Key="WindowControlTemplate" TargetType="{x:Type Window}" >
<Border x:Name="WinControlTpl_Border" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" BorderBrush="#FF4C95BA" BorderThickness="1" Background="White" CornerRadius="4" Padding="1">
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform CenterX="400" CenterY="300" />
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Border.RenderTransform>
<Grid Background="{StaticResource WindowBackground}">
<AdornerDecorator>
<ContentPresenter/>
</AdornerDecorator>
<ResizeGrip x:Name="WindowResizeGrip" HorizontalAlignment="Right" VerticalAlignment="Bottom" />
</Grid>
</Border>
<ControlTemplate.Resources>
<Storyboard x:Key="OnLoaded1">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="WinControlTpl_Border" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.0"/>
<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="WinControlTpl_Border" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.5"/>
<SplineDoubleKeyFrame KeyTime="00:00:00.1500000" Value="1"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="WinControlTpl_Border" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.5"/>
<SplineDoubleKeyFrame KeyTime="00:00:00.1500000" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</ControlTemplate.Resources>
<ControlTemplate.Triggers>
<Trigger Property="ResizeMode" Value="CanResizeWithGrip">
<Setter TargetName="WindowResizeGrip" Property="Visibility" Value="Visible"/>
</Trigger>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource OnLoaded1}"/>
</EventTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
code_long
WPF/Silverlight 8,757 成员 12,031 内容