正在运行 Visual Studio 2017,并且目标为 .NET 4.6.1。考虑以下 XAML
。在 XAML 编辑器中,您可以看到两个圆,但在运行应用程序时,只会显示第二个圆。
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Window.Resources>
<Viewbox x:Key="MyBox" Stretch="Uniform">
<Ellipse Width="4" Height="4" Fill="Red"/>
</Viewbox>
</Window.Resources>
<StackPanel>
<ContentPresenter Width="100" Content="{StaticResource MyBox}"/>
<ContentPresenter Width="100" Content="{StaticResource MyBox}"/>
</StackPanel>
</Window>
您如何重复使用一个
Viewbox
资源?