我有资源字典文件(MenuTemplate.xaml,ButtonTemplate.xaml等),我想在多个单独的应用程序中使用.我可以将它们添加到应用程序的程序集中,但如果我在一个程序集中编译这些资源并让我的应用程序引用它,那就更好了吧?
构建资源程序集后,如何在我的应用程序的App.xaml中引用它?目前,我使用ResourceDictionary.MergedDictionaries来合并各个字典文件.如果我在一个程序集中有它们,我怎么能在xaml中引用它们?
我想将一个项目移动到 WPF,其中有一个ImageList(通过在设计视图中选择 25 个图像来加载),我用它来创建按钮,如下所示: 我已将项目简化为以下代码。这是我的整个项目(除了 .Designer.cs 中自动生成的代码):
public partial class Form1 : Form
{
Button[] buttonList = new Button[25];
Size buttonSize = new Size(140, 140);
public Form1()
{
InitializeComponent();
this.ClientSize = new Size(142 * 5, 142 * 5);
for (int i = 0; i < buttonImages.Images.Count; i++)
{
buttonList[i] = new Button();
buttonList[i].Size = buttonSize;
buttonList[i].Location = new Point(
(i % 5) * (buttonSize.Width + 2) + 1,
(i / 5) * (buttonSize.Height + 2) + …Run Code Online (Sandbox Code Playgroud)