在哪里添加引用名称空间的标记? [英] Where add tag referenced to a namespace?

查看:65
本文介绍了在哪里添加引用名称空间的标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!



这是我的问题:



最初,我只有一个项目(MainProject)有一个全局ResourceDictionary(StyleResources),类等。项目正在增长,我决定将资源分成新项目(SecondaryProject)。



第一个问题:如果它只包含ResourcesDictionaries,那么什么项目类型应该是SecondaryProject?这个项目必须有MainWindow.xaml,App.xaml ...文件?



继续解释...

其中一个初始样式(TabItemStyle)我使用了一个转换器,它在命名空间Converter中定义了一个名为TabSizeConverter的类,并使用下一个代码让它工作。这是包含在inicial StyleResources文件中的代码:



- xmlns:local =clr-namespace:Converters

- < local :tabsizeconverter x:key =tabSizeConverter/>



第二个问题:现在,使用我的新配置,如何让它正常工作再次?我有一个错误,因为它找不到TabSizeConverter类,它不能克服这种类型。



谢谢和问候:

Hi to all!

Here is my problem:

Initially, I only had a project (MainProject) with a global ResourceDictionary (StyleResources), classes, etc. The project was growing, and I decided to separate the resources into new project (SecondaryProject).

First question: What project type should be SecondaryProject if it only contains ResourcesDictionaries? This project must have MainWindow.xaml, App.xaml... files?

Continuing with the explanation...
In one of the initial styles (TabItemStyle) I used a converter that it was define in a namespace "Converter" with a class named TabSizeConverter and using next code I get it to work. This was the code including at inicial StyleResources file:

- xmlns:local="clr-namespace:Converters"
- <local:tabsizeconverter x:key="tabSizeConverter" />

Second question:Now, with my new configuration, how to get it working again? I am having an error because It can´t find TabSizeConverter class and it can´t crete this type.

Thanks and regards:

推荐答案

你好Torin86,

如果我理解你的问题,你可以尝试下面提到的。



步骤1:右键单击当前解决方案,然后选择添加新项目 - > WPF应用程序。 (这可以包含Main.xaml和资源文件)。

步骤2:在新创建的项目中,右键单击,然后选择属性。选择应用程序,然后将输出类型更改为类库。

步骤3.构建新创建的项目,该项目将创建.dll文件。

步骤4.在主项目单击Reference并将此新项目.dll文件添加为项目参考。

步骤5.在Main项目.xaml文件中,使用pack可以引用新项目中的样式和转换器。



Hi Torin86,
If i understood your question correctly, you can try below mentioned.

Step 1: Right click on the current solution and Select Add New Project -> WPF Application. (This can have the Main.xaml and resource files).
Step 2: In the Newly created project, Right click then select "Properties". Select Application and then change the Output type to "Class Library".
Step 3. Build the newly created project which will create .dll file.
Step 4. In the Main Project click on Reference and add this new project .dll file as project reference.
Step 5. In the Main project .xaml file use the pack assmebly to refer the styles and converter present in the new project.

<ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/NewprojectName;component/StyleXamlfileName.xaml"/>
            </ResourceDictionary.MergedDictionaries>
<ResourceDictionary>





步骤6.构建并检查它应该可以正常工作。







希望我能帮到你。



谢谢

Sriram.B



Step 6. Build and check it should work fine.



Hope I help you.

Thanks
Sriram.B


这篇关于在哪里添加引用名称空间的标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆