【发布时间】:2016-05-11 17:32:05
【问题描述】:
我有一个要在其中添加 Viewbox 的 UserControl。 Viewbox 在我项目的另一个 xaml 文件中。我尝试了很多(类似 ResourceDictionaries)......但失败了。这是我的最小示例:
用户控制:
<UserControl ......>
<Grid>
<!--Here I want the Viewbox (MyPicture.xaml)-->
</Grid>
</UserControl>
MyPicture.xaml
<Viewbox Width="16" Height="16" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<Rectangle ... />
</Viewbox>
希望有人可以帮助我。
【问题讨论】:
-
MyPicture.xaml文件中没有其他内容?这个想法背后的基本原理是什么? -
没有别的。我只想将此 ViewBox 保存在外部文件中。
-
所以你不能使用
ResourceDictionary也不能控制/用户控制?你为什么决定使用这种方法真的很有趣。 -
我的计划是在不同的文件中拆分不同的视图框。因此更容易更改它们并在其他应用程序中重用。
标签: c# .net wpf xaml user-controls