gpt4 book ai didi

wpf - 尝试卡住填充有 BitmapCacheBrush 的矩形时出错

转载 作者:行者123 更新时间:2023-12-02 04:34:05 28 4
gpt4 key购买 nike

我正在尝试卡住 BitmapCacheBrush,但当我调用“卡住”时,会出现错误,指出无法卡住它。

我想做的是用 BitmapCacheBrush 填充一个矩形,然后在某个时刻将其卡住,这样我就可以为矩形设置动画并重用源网格来做其他事情(在为矩形设置动画时)。

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50*"></RowDefinition>
<RowDefinition Height="50*"></RowDefinition>
</Grid.RowDefinitions>

<Grid x:Name="LISTING">
<Grid.CacheMode>
<BitmapCache RenderAtScale="1" SnapsToDevicePixels="True"/>
</Grid.CacheMode>
<Rectangle x:Name="Rectangle1" Fill="Red" />

<Label Content="Test" FontSize="20" Foreground="Black" />
<Button x:Name="Button1" Click="Button1_Click"/>
</Grid>

<Rectangle Grid.Row="1" x:Name="Rectangle2" >
<Rectangle.Fill>
<BitmapCacheBrush x:Name="BMCB" Target="{Binding ElementName=LISTING}"/>
</Rectangle.Fill>
</Rectangle>
</Grid>

在我的测试中,我试图查看单击按钮时是否可以卡住 BMCB BitmapCacheBrush,然后作为测试,我想隐藏按钮并仍然看到底部矩形完好无损。

我想使用 BitmapCacheBrush 来提高性能。

这可能吗?

谢谢本

最佳答案

我会说不:但我证明这一点的唯一来源是 Freezable documentation在 msdn 中,它说:

A Freezable can't be frozen if any of the following are true:

  • It has animated or data bound properties.
  • It has properties set by a dynamic resource.
  • It contains Freezable sub-objects that can't be frozen.

所以我猜你无法卡住它,因为你的 Target="{Binding ElementName=LISTING}" 绑定(bind)。

关于wpf - 尝试卡住填充有 BitmapCacheBrush 的矩形时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7659940/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com