|
I don't think there is any requirement that it be an http string. It can be pretty much anything. Http is just what people use because its easy to remember (way easier then URI syntax), and it looks cool.
|
|
|
|
|
I was actually wondering about that... I think it would have made more sense to use "ns://"... Does anyone actually memorize it anyway? If it wasn't for Intellisense, I'd be looking it up online every time.
EDIT: Hmm, after seeing Pete's link... Guess using HTTP is logical... Just being standards-compliant.
|
|
|
|
|
|
Makes a change
|
|
|
|
|
Ian Shlasko wrote: I agree that using "http" as the prefix is kind of silly (I'm guessing there was
some sort of reason for it, but not looking it up right now)... But it
works.
There is a perfectly valid reason. Remember that XAML is XML Application Markup Language; the use of the URI is in line with the convention for assigning namespaces in XML. There's an "interesting" read on XML Namespaces here[^].
|
|
|
|
|
that's a long reading... yike. you think it's worthwhile? (although i've started reading it...)
dev
|
|
|
|
|
devvvy wrote: you think it's worthwhile?
Not really. That's why I put quotes around interesting - it was being ironic.
|
|
|
|
|
W3 docs really are impenetrable
|
|
|
|
|
Hi guys,
I think I have the answers - collected from couple places posting here to share with everybody
In Xaml root element "Window" or "UserControl", one would typically find:
<br />
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"<br />
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" <br />
xmlns:Infra="http://infragistics.com/DockManager" <br />
xmlns:MyLib1="clr-namespace:AbcFirm.Lib1"<br />
xmlns:MyLib2="clr-namespace:AbcFirm.Lib2" <br />
xmlns:MyLib3="clr-namespace:AbcFirm.Lib3" <br />
xmlns:sys="clr-namespace:System;assembly=mscorlib"<br />
1. Default namespaces
--------------------------------------------------------
One point worth noting, defaults reference CANNOT be removed, or changed even though XamlParser won't go online and visit the actual reference
<br />
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"<br />
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"<br />
Give it a try. If you remove or change these two defaults, you'd get compiler error. The following would NOT compile for instance.
<br />
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentationXXXXX"<br />
xmlns:x="http://schemas.microsoft.com/winfx/2006/xamlXXXXX"<br />
xmlns:sys="clr-namespace:System;assembly=mscorlib"<br />
These two defaults namespaces are probably defined in "XmlnsDefinition" tag in "AssemblyInfo.cs" of WPF dll.
<code>
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation[^]", "")]
[assembly: XmlnsDefinition("http"//ImUseless.com/DoNothing[^]", "x")]
</code>
So while Xaml processor wont go online and actually parsed the referenced url's - they are compiled into the referenced dll's and you cannot just put some garbage there!
This is described on MSDN[^]
<br />
The root element also contains the attributes xmlns and xmlns:x. These attributes indicate to a XAML processor which XAML namespaces contain the type definitions for backing types that the markup will reference as elements. The xmlns attribute specifically indicates the default XAML namespace. Within the default XAML namespace, object elements in the markup can be specified without a prefix. For most WPF application scenarios, and for almost all of the examples given in the WPF sections of the SDK, the default XAML namespace is mapped to the WPF namespace http:
2. Custom namespaces
---------------------------------------------------------------
For actual namespace reference, which doesn't reference "Url" - they are for real, referenced namespace must exists (Or else compile error).
<br />
xmlns:MyLib1="clr-namespace:AbcFirm.Lib1" <br />
xmlns:MyLib2="clr-namespace:AbcFirm.Lib2" <br />
xmlns:MyLib3="clr-namespace:AbcFirm.Lib3" <br />
xmlns:sys="clr-namespace:System;assembly=mscorlib"<br />
xmlns:igDock="http://infragistics.com/DockManager" << NOTE: You don't necessarily need to use "clr-namespace", you can rely on [assembly: XmlnsDefinition] instead)<br />
In above example, you'd find from "AssemblyInfo.cs" (you'd need to add "using System.Windows.Markup") of relevant Infragistics's dll something similar to:
<br />
[assembly: XmlnsDefinition("<a href="http:
dev
modified on Thursday, April 28, 2011 10:56 PM
|
|
|
|
|
devvvy wrote: xmlns:MyLib1="clr-namespace:AbcFirm.Lib1" < Cool, no useless Url's
devvvy wrote: xmlns:Infra="http://infragistics.com/DockManager" < Why....
I'll answer this one by considering both cases. With the clr-namespace declaration, you have to add each assembly in to your namespace mapping, one at a time. With the URI version, you can add one declaration and get multiple DLLs referenced in one go. Instead of having xmlns:MyLib1 , xmlns:MyLib2 and xmlns:MyLib3 , your example would just need xmlns:MyLib="http://ImUseless.com/DoNothing" .
|
|
|
|
|
thanks but I found the answer!
dev
|
|
|
|
|
Hello friends,
I have a datagrid having a column name as Download and I have kept a hyperlink button for that.
On that hyperlink button click,I want to open an csv file whose path is in database.The path is like:
D:\Project\SynchModule\SynchModuleSL.Web\Pendings\new 1_2.csv
and the file does exists in Pending Folder.
How do I open that file on Hyperlink button click??
Please treat this as an urgent thread.
pls reply
Thanks
Piyush
|
|
|
|
|
Piyush Nandanwar wrote: Please treat this as an urgent thread.
Here's a friendly piece of advice: that's not the way the forums work. This is a volunteer only site - you aren't paying for support, so you get answers based on the timescales of the poster, not on any arbitraty timescale you have to work to.
Saying that, what you should look at is using the WebClient class to download the file as an asynchronous file from the server to the client (the clues to the code you need to write are all in that sentence). You do need to be aware that your web server must have permissions to read from the folder.
|
|
|
|
|
Hi Pete
Suppose,I have permissions to access the files from server.What should I write in code to open the csv file,on hyperlink button click??
|
|
|
|
|
Well, you could always google Silverlight WebClient download file and see what you get. I did say that all the clues were in my original post. In future, I'd expect you to at least try to write the code yourself - honestly, it's not that hard. As I'm in a good mood though, you're going to need a variation of this:
private void DownloadFileClick(object sender, RoutedEventArgs e)
{
var webClient = new WebClient();
webClient.OpenReadCompleted += new webClient_OpenReadCompleted;
webClient.OpenReadAsync(new Uri(the path to the url here, UriKind.Absolute));
}
void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
bool? result = sfd.ShowDialog();
if (result.HasValue && result.Value == true)
{
using (var sr = new StreamReader(e.Result))
{
string str = sr.ReadToEnd();
using (var sw=new StreamWriter(sfd.OpenFile()))
{
sw.Write(str);
}
}
}
}
|
|
|
|
|
Well,I am facing an error as "Dialogs must be user-initiated."
on -- bool? result = sfd.ShowDialog(); -- line.
|
|
|
|
|
That was just an example I typed into the textbox here. Honestly, I've given you most of the code - you can sort this one out for yourself.
|
|
|
|
|
|
Hi,
In the datagrid, I would like to format the AmountPaid column to show the £ infront of it.
At present it just shows the AmountPaid figures without the £ sign.
Note that in the xaml, I have placed the following but it shows $
<DataGridTextColumn Header="Amount Paid" Width="90" Binding="{Binding AmountPaid, StringFormat={}{0:C}}"></DataGridTextColumn>
Previously in windows forms datagridview, I could get the £ sign infront of the AmountPaid by using the following c# code.
datagrid.Columns["AmountPaid"].DefaultCellStyle.Format = "C";
Any thoughts how to do this in WPF please?
Thanks
|
|
|
|
|
|
I tried placing the following line in the constructor of my window but there is an unerline error for XmlLanguagebecause it says the name XmlLanguage does not exist in the current context.
Do you see why?
Thanks
public frmStudentDetails()
{
InitializeComponent();
this.Language = XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentCulture.Name);
}
|
|
|
|
|
You need to add a reference to System.Windows.Markup .
Hope this helps
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....
|
|
|
|
|
|
Rather than relying on the inbuilt formatter, which has a number of shortcomings with regards to internationalisation, I tend to use a custom value converter (partly because I deal with financial software a lot, where it's common to convert a negative number to sit inside brackets). This makes for a very flexible solution, and allows you to change the language format mid application with ease.
|
|
|
|
|
Do you mean like a converter class which has a method to accept the currency and return it with the £ infront of it?
|
|
|
|