canvas 按钮内容消失
canvas button content disappears
我正在处理的项目中出现了一些奇怪的行为。
有问题的代码:
<Button cal:Message.Attach="DeleteThruster($dataContext)" ToolTip="Delete">
<Button.Content>
<ContentPresenter Content="{StaticResource appbar_delete}">
<ContentPresenter.LayoutTransform>
<ScaleTransform ScaleX="0.5" ScaleY="0.5" />
</ContentPresenter.LayoutTransform>
</ContentPresenter>
</Button.Content>
</Button>
<Button Margin="5,0,20,0" cal:Message.Attach="CopyThruster($dataContext)" ToolTip="Copy">
<Button.Content>
<ContentPresenter Content="{StaticResource appbar_page_copy}">
<ContentPresenter.LayoutTransform>
<ScaleTransform ScaleX="0.5" ScaleY="0.5" />
</ContentPresenter.LayoutTransform>
</ContentPresenter>
</Button.Content>
</Button>
<Canvas x:Key="appbar_delete" Width="76" Height="76" Clip="F1 M 0,0L 76,0L 76,76L 0,76L 0,0">
<Path Width="27.7083" Height="35.625" Canvas.Left="24.1458" Canvas.Top="19.7917" Stretch="Fill" Fill="{DynamicResource BlackBrush}" Data="F1 M 25.3333,23.75L 50.6667,23.75C 51.5411,23.75 51.8541,27.3125 51.8541,27.3125L 24.1458,27.3125C 24.1458,27.3125 24.4589,23.75 25.3333,23.75 Z M 35.625,19.7917L 40.375,19.7917C 40.8122,19.7917 41.9583,20.9378 41.9583,21.375C 41.9583,21.8122 40.8122,22.9584 40.375,22.9584L 35.625,22.9584C 35.1878,22.9584 34.0416,21.8122 34.0416,21.375C 34.0416,20.9378 35.1878,19.7917 35.625,19.7917 Z M 27.7083,28.5L 48.2916,28.5C 49.1661,28.5 49.875,29.2089 49.875,30.0834L 48.2916,53.8334C 48.2916,54.7078 47.5828,55.4167 46.7083,55.4167L 29.2917,55.4167C 28.4172,55.4167 27.7083,54.7078 27.7083,53.8334L 26.125,30.0834C 26.125,29.2089 26.8339,28.5 27.7083,28.5 Z M 30.0833,31.6667L 30.4792,52.25L 33.25,52.25L 32.8542,31.6667L 30.0833,31.6667 Z M 36.4167,31.6667L 36.4167,52.25L 39.5833,52.25L 39.5833,31.6667L 36.4167,31.6667 Z M 43.1458,31.6667L 42.75,52.25L 45.5208,52.25L 45.9167,31.6667L 43.1458,31.6667 Z "/>
</Canvas>
由于某些奇怪的原因,当我 运行 我的程序并单击复制按钮时,以前的按钮将丢失其内容,即 canvas 图像。更令人恼火的是,它在设计器中呈现得很好。
这种错误的行为是否给任何人敲响了警钟?
此处提供源代码:
GitHub project / specific file
我在使用 canvas 制作的图标时遇到了同样的问题。我的问题的解决方案是将 x:Shared="False" 添加到我的 Canvas.
例如
<Canvas x:Key="appbar_delete" x:Shared="False" .../>
希望这会解决它。出于好奇,你打算用你的程序做什么?看起来很有趣...
问候
桑霍洛
我正在处理的项目中出现了一些奇怪的行为。
有问题的代码:
<Button cal:Message.Attach="DeleteThruster($dataContext)" ToolTip="Delete">
<Button.Content>
<ContentPresenter Content="{StaticResource appbar_delete}">
<ContentPresenter.LayoutTransform>
<ScaleTransform ScaleX="0.5" ScaleY="0.5" />
</ContentPresenter.LayoutTransform>
</ContentPresenter>
</Button.Content>
</Button>
<Button Margin="5,0,20,0" cal:Message.Attach="CopyThruster($dataContext)" ToolTip="Copy">
<Button.Content>
<ContentPresenter Content="{StaticResource appbar_page_copy}">
<ContentPresenter.LayoutTransform>
<ScaleTransform ScaleX="0.5" ScaleY="0.5" />
</ContentPresenter.LayoutTransform>
</ContentPresenter>
</Button.Content>
</Button>
<Canvas x:Key="appbar_delete" Width="76" Height="76" Clip="F1 M 0,0L 76,0L 76,76L 0,76L 0,0">
<Path Width="27.7083" Height="35.625" Canvas.Left="24.1458" Canvas.Top="19.7917" Stretch="Fill" Fill="{DynamicResource BlackBrush}" Data="F1 M 25.3333,23.75L 50.6667,23.75C 51.5411,23.75 51.8541,27.3125 51.8541,27.3125L 24.1458,27.3125C 24.1458,27.3125 24.4589,23.75 25.3333,23.75 Z M 35.625,19.7917L 40.375,19.7917C 40.8122,19.7917 41.9583,20.9378 41.9583,21.375C 41.9583,21.8122 40.8122,22.9584 40.375,22.9584L 35.625,22.9584C 35.1878,22.9584 34.0416,21.8122 34.0416,21.375C 34.0416,20.9378 35.1878,19.7917 35.625,19.7917 Z M 27.7083,28.5L 48.2916,28.5C 49.1661,28.5 49.875,29.2089 49.875,30.0834L 48.2916,53.8334C 48.2916,54.7078 47.5828,55.4167 46.7083,55.4167L 29.2917,55.4167C 28.4172,55.4167 27.7083,54.7078 27.7083,53.8334L 26.125,30.0834C 26.125,29.2089 26.8339,28.5 27.7083,28.5 Z M 30.0833,31.6667L 30.4792,52.25L 33.25,52.25L 32.8542,31.6667L 30.0833,31.6667 Z M 36.4167,31.6667L 36.4167,52.25L 39.5833,52.25L 39.5833,31.6667L 36.4167,31.6667 Z M 43.1458,31.6667L 42.75,52.25L 45.5208,52.25L 45.9167,31.6667L 43.1458,31.6667 Z "/>
</Canvas>
由于某些奇怪的原因,当我 运行 我的程序并单击复制按钮时,以前的按钮将丢失其内容,即 canvas 图像。更令人恼火的是,它在设计器中呈现得很好。
这种错误的行为是否给任何人敲响了警钟?
此处提供源代码: GitHub project / specific file
我在使用 canvas 制作的图标时遇到了同样的问题。我的问题的解决方案是将 x:Shared="False" 添加到我的 Canvas.
例如
<Canvas x:Key="appbar_delete" x:Shared="False" .../>
希望这会解决它。出于好奇,你打算用你的程序做什么?看起来很有趣...
问候 桑霍洛