WinUI Using Merged Dictionary from a DLL - winrt-xaml

I have this requirement where I need to access a resource dictionary defined in a DLL in my project as a merged dictionary. The whole project is setup as a C++/WinRT xaml hosted MFC application. And the required ResourceDictionary is a part of another dll.
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="PathToDict/CommonDictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
As shown here in the Source property, CommonDictionary.xaml exists as part of another projects binary(dll) and I need to merge that file to my project by specifying the a path to it.
I've already tried something like this although this works only for WPF;
<ResourceDictionary Source="pack://application:,,,/myNameSpace;component/CommonDictionary.xaml"/>
And also tried this after adding a reference to the project;
<ResourceDictionary Source="ms-appx:///MyNamespace/CommonDictionary.xaml"/>
None of these seem to work.

if your file in project directory, try to use
<ResourceDictionary Source="ms-appx:///CommonDictionary.xaml"/>
Generally, you can open any Page.g.i.cs file and see any string with Uri define. For example:
global::System.Uri resourceLocator = new global::System.Uri("ms-appx:///View/Page.xaml");

Related

how to point root folder of DAM Display portlet programatically

How to set one of the folders as root folder of Documents And Media Display portlet by programmatically.PFA image
Liferay Major Version
Your question is tagged as Liferay 6 and Liferay 7. The two releases are drastically different. This answer assumes you are using Liferay 6.x since you are asking about the DDM portlet as opposed to the OSGI module.
Programmatically setting that input resource to default as a folder of your choice requires you to create a JavaServer Page hook for a JSP in the Document Library Display portlet. I am going to briefly explain how to create the JSP hook before getting into particulars.
Create a Hook
From Liferay's Knowledge base
From your command line terminal, navigate to your Plugins SDK’s hooks folder. To create a hook project, you must execute the create script. Here’s the format to follow in executing the script:
create.[sh|bat] [project-name] "[Hook Display Name]"
On Linux and Mac OS X, you’d enter a command similar to the one in this example:
./create.sh doc-lib-disp-hook "Document Library Display Hook"
On Windows, you’d enter a command similar to the one in this example:
create.bat doc-lib-disp-hook "Document Library Display Hook"
Liferay IDE’s New Project wizard and the create scripts generate hook projects in your Plugin SDK’s hooks folder. The Plugins SDK automatically appends “-hook” to your project name.
You will need to have Apache ANT installed for this to work. Please reference the following documentation if you need to install it.
https://www.mkyong.com/ant/how-to-install-apache-ant-on-windows/
Once the hook is created open it in your Liferay IDE or Liferay Developers Studio (or Eclipse).
In your IDE click the down arrow right below File (top left corner)
Choose Liferay Plugin Project from Existing Source
Double click on the doc-lib-disp-hook folder in your Plugin's SDK Hook directory to open.
You should see something similar to this (with different name).
Override JSP
Now that you have successfully created a hook plugin, we need to override the necessary file. There are two files in particular that we need for this hook
html/portlet/document_library_display/configuration.jsp
html/portlet/document_library/init.jsp
We need both files to logically walk through this example although we only need to actually override one of them.
To override the JSP's execute the following steps
Under your META-INF folder create a new directory called custom_jsp
Open up liferay-hook.xml in Overview mode
Click the Green Plus sign (to the right of Custom JSP label)
Search for both files listed above (copy and paste the URL into the window) then click save.
You will now notice you have the following directory structure.
Let's first open the configuration.jsp. This is the code that produces the GUI you took a screen shot of. Find the following code block.
<aui:field-wrapper label="root-folder">
<div class="input-append">
<liferay-ui:input-resource id="rootFolderName" url="<%= rootFolderName %>" />
<aui:button name="openFolderSelectorButton" value="select" />
<%
String taglibRemoveFolder = "Liferay.Util.removeFolderSelection('rootFolderId', 'rootFolderName', '" + renderResponse.getNamespace() + "');";
%>
<aui:button disabled="<%= rootFolderId <= 0 %>" name="removeFolderButton" onClick="<%= taglibRemoveFolder %>" value="remove" />
</div>
</aui:field-wrapper>
Inside that block you will see the Root Folder element you wish to set.
<liferay-ui:input-resource id="rootFolderName" url="<%= rootFolderName %>" />
As you can see the folder's url is already set by default to the variable rootFolderName. We need to find where that variable is first initialized.
We need not modify this file at all. I had you include it and open it so you can follow through logically.
If you notice rootFolderName is not initialized anywhere in the configuration.jsp file. Therefore we need to investigate the init.jsp file because it is an include at the top of the page. If you open that file you will notice the following block.
String portletResource = ParamUtil.getString(request, "portletResource");
if (layout.isTypeControlPanel()) {
portletPreferences = PortletPreferencesLocalServiceUtil.getPreferences(themeDisplay.getCompanyId(), scopeGroupId, PortletKeys.PREFS_OWNER_TYPE_GROUP, 0, PortletKeys.DOCUMENT_LIBRARY, null);
}
long rootFolderId = PrefsParamUtil.getLong(portletPreferences, request, "rootFolderId", DLFolderConstants.DEFAULT_PARENT_FOLDER_ID);
String rootFolderName = StringPool.BLANK;
if (rootFolderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
try {
Folder rootFolder = DLAppLocalServiceUtil.getFolder(rootFolderId);
rootFolderName = rootFolder.getName();
}
catch (NoSuchFolderException nsfe) {
}
}
This code is basically saying we are going to initialize rootFolderName blank. However if rootFolderId is set higher than 0 either by
Portlet preferences, or
Request Parameters
then we will set rootFolderName accordingly.
Conclusion
If you want to set rootFolderName to a folder of your choice programmatically by default you can a few things. The easiest thing to do would be to get the folder's id and modify the code like this
long folderIdConstant = 999999L; // place folder id here
long rootFolderId = PrefsParamUtil.getLong(portletPreferences, request, "rootFolderId", folderIdConstant );
That would set the default root folder programmatically. Just build and deploy now.

How to include templates into VSIX package

I am developing a package for VS2012 and what I have there is:
A custom project template and a set of custom item templates:
Templates\Items\MyFirstItem (and more items there), Templates\Projects\MyProject
Each template item contains .vstemplate file which is set to VSTemplate build action.
A Package which registers a ProjectFactory in a way:
[ProvideProjectFactory(
typeof(MyProjectFactory),
null,
"My Project Files (*.myproj);*.myproj",
"myproj", "myproj",
#".\\NullPath",
LanguageVsTemplate = "MyProject")]
A "Create VSIX Container during the build" option is set for the project.
When I build the project I see that my templates are zipped correctly and are copied into the output folder as expected such as bin\Debug\ItemTemplates\... and bin\Debug\ProjectTemplates.
They are also installed properly into the experimental instance.
However, these templates are NOT getting included into .vsix file.
And there is the question: how do I make them included without zipping them manually and including these zip files as assets into the source.extension.vsixmanifest?
You have to add those to the source.extension.vsixmanifest designer in your VSIX project. There is an Assets section and you basically just click New, select ItemTemplate from the type dropdown, select Current solution or project, then choose your item template. Repeat for every item template.

Path to layout xml files in magento

I have seen that we can place our layout xml files in
app/design/frontend/default/default/layout
or we can place our customization inside
app/design/frontend/base/default/layout/local.xml
file, but I have read at magebase and at magentocommerce that we can place our layout files under
app/design/frontend/your_interface/your_theme/layout/
or
app/design/frontend/[package]/[theme]/layout
So if we I have package like 'Kaushikamdotcom' in 'app/code/local', should I have to create that same package under 'app/design/frontend/' ? I tried many patterns, but nothing worked out for me.
I am quite sorry that I have made such a blunder asking this question, but I am answering this as lots of people will be making the same mistake. Package means; in the admin side of magento open
System->Configuration->Design
Then change the configuration scope to Main website. Then select Package section, uncheck the default check box and use your package name such as "Test". Then create the following folder structure.
app/design/frontend/Test/default/layout
Place your layout xml files here. If you are using your own themes use that name instead of default.
It depends what layout-xml file you have.
If you want to build up your theme, use the local.xml file in your theme dir.
If you write an extension and want to add a block to use inside this new extension, add a layout-xml file via config.xml and add it under base/default/layout/yourname.xml
When you do it this way, your theme-related changes only appear in the theme and your extension-related changes are theme-independent

Include javascript file in sharepoint visual web part

I am using sharepoint 2010 and developing a visual web part. I had javascript functions on the ascx file and they all used to work file.Now I have moved them to a single javascript.js file and deployed it to the _layouts folder on server.
And I have put the below line on the ascx file to reference to that file
<script src="/sites/xxxxx/_layouts/customwebparts/javascript.js" type="text/javascript"> </script>
and then on the ascx.cs file and I am using the methods defined in this file for eg.,
btnCancel.Attributes.Add("onclick", "{return Action(Cancel the form?)};");
But it is not working, it is not displaying the confimration box ...Am I referencing the wrong way. Please help me ....
To reference a javascript file from within a SharePoint Visual Web Part you need to use the SharePoint:ScriptLink tag (example below):
<SharePoint:ScriptLink ID="<someid>" runat="server" Name="/_layouts/...<Path>"></SharePoint:ScriptLink>
I add a layouts mapped folder to my Visual Web Part project and place a scripts folder within the default folder, which I believe is the projects name. Following this model ensures that the javascript file is always kept up-to-date during deployment. The 'Name' property in the above tag is just the path to the javascript file relative to _layouts, so something like "/_layouts/ProjectName/Scripts/myjavascript.js".
As an FYI if you want to use CSS as well there is a SharePoint:CssRegistration tag as well. I find these are the 2 that I use the most.
You should put your javascript file in the Layout mapped folder and use the SharePoint:ScriptLink tag:
<SharePoint:ScriptLink id="ScriptLink1" runat="server" Localizable="false" Name="some-layout-subfolder/file.js" />
If you have a file not found error you should check that the Localizable attribute is set to false and from Visual Studio, in the properties of the js file, Build Action should be set as Content and Deployment Type should be TemplateFile.
Check here for more details:
http://blog.netgloo.com/2014/06/19/include-javascript-and-css-files-in-your-sharepoint-2010-visual-web-part/

Disable source parameter on links

Brief description of the default behavior i want to override:
Creating a SharePoint list and using the "Title (linked to Item)" in a view provides a link to the DispForm for that list. By default, this link appends a Source parameter to the URL query string.
I would like to disable this behavior in some way while still retaining the default list view web part that is created by SharePoint when the view is defined.
To be clear, I know how to convert the list-view webpart to XSLT and then control this behavior. If at all possible, I'd like to keep from doing that so that the list view can still be easily supported by Help Desk and also keep the benefits of the standard list view (such as exporting to excel and so forth).
Any ideas?
Thanks in advance for your help.
Troy
SharePoint (2007) dynamically appends the source parameter in a javascript method named GoToLink. That method is defined in SharePoint's core.js file, and it can be easily customized without editing the original file. In fact, you never want to edit that file directly; it will put SharePoint into an "unsupported" state.
We'll create a solution for our customization, so it can easily be deployed or retracted in a consistent manner. Create a new Empty SharePoint solution in Visual Studio, targeted for GAC deployment. Within your project, create the following folder structure:
Templates
Layouts
1033
("1033" is for the English localization; if you're using a different language, your id will be different).
Within "1033", create a new Javascript file (we call our ours "CustomCore.js"). This will contain JUST the code we want to override from Core.js. Since GoToLink is the only thing we're interested in, let's focus on that. Here's the original from Core.js:
function GoToLink(elm) {
if (elm.href==null)
return;
var ch=elm.href.indexOf("?") >=0 ? "&" : "?";
var srcUrl=GetSource();
if (srcUrl !=null && srcUrl !="")
srcUrl=ch+"Source="+srcUrl;
var targetUrl=elm.href+srcUrl;
if (isPortalTemplatePage(targetUrl))
window.top.location=STSPageUrlValidation(targetUrl);
else
window.location=STSPageUrlValidation(targetUrl);
}
Not much to it. For our override, we just need to omit the bits that add the source parameter. From my reckoning, the modified method looks like this:
function GoToLink(elm) {
if (elm.href==null)
return;
if (isPortalTemplatePage(elm.href))
window.top.location=STSPageUrlValidation(elm.href);
else
window.location=STSPageUrlValidation(elm.href);
}
That should be it. Package up the solution and Visual Studio should interpret the "Templates" folder structure correctly when it builds the WSP (look in the generated manifest file for the TemplateFile element and that it's deploying to "Layouts\1033\CustomCore.js").
Once your WSP solution is deployed to SharePoint, we have the final step of referencing it in your Master page. In the HEAD section of your master page, you should see Core.js being referenced like this:
<SharePoint:ScriptLink Language="javascript" runat="server" Defer="True" Name="core.js"/>
We simply add a reference to the new JS file directly beneath this line:
<SharePoint:ScriptLink Language="javascript" runat="server" Defer="True" Name="core.js"/>
<SharePoint:ScriptLink Language="javascript" runat="server" Defer="True" Name="customcore.js"/>
Test it out and make sure it works. Note that this will affect ALL lists on the server to which you've deployed "CustomCore.js" and which use the master page.

Resources