How to Link External Websites to Windows Phone Pages using C#/VB.NET
Once you create a +Windows Phone application with content, you will have a necessity to link it to multiple websites (External etc).
You can use either HyperlinkControl or the Hyperlink XAML Tag to achieve that.
Let's take our Sample App (refer QR Code) which has a good list of Hotels and Restaurants.
The App tries to provide links to these websites.
Adding Hyperlink Tag to the Content/Grid should help.
Exceptions while Adding Hyperlink / Navigating Hyperlink in Windows Phone Application
{"Cannot navigate to locations relative to a page."}
{"Navigation is only supported to relative URIs that are fragments, or begin with '/', or which contain ';component/'.\r\nParameter name: uri"}
The above exceptions are caused when the TargetName is not set to _blank
(or)
The http:// prefix is omitted in NavigateUri
The correct representation is given below:
<Hyperlink TargetName="_blank" NavigateUri="http://www.hotelnalaresidency.com">www.hotelnalaresidency.com</Hyperlink>
The +Silverlight code worked perfectly bringing the Website as shown below
See also:
Hyperlink Control in Windows Forms (VB.NET) Application
How to Download File from Website using C# (.NET)
Tuesday, June 18, 2013
Windows Phone/Silverlight application The type or namespace name 'XmlTextReader' could not be found (are you missing a using directive or an assembly reference?)
Windows Phone/Silverlight application The type or namespace name 'XmlTextReader' could not be found (are you missing a using directive or an assembly reference?)
XmlTextReader or XmlDocument aren't supported in Silverlight. Hence use XMLReader for reading XMLDocuments
See also:
How to Add/Load XAML Dynamically to RichTextBox Control - Windows Phone Development C#/VB.NET
Create XML Files using .NET / Create XML Files using C#
Convert an XML file to HTML file using C#
How to Get All Elements of an XML using C# (.NET)
How to add XML Declaration to an XML document using C# (.NET)
Remove DOCTYPE declaration from XML Files using C#
XmlTextReader or XmlDocument aren't supported in Silverlight. Hence use XMLReader for reading XMLDocuments
See also:
How to Add/Load XAML Dynamically to RichTextBox Control - Windows Phone Development C#/VB.NET
Create XML Files using .NET / Create XML Files using C#
Convert an XML file to HTML file using C#
How to Get All Elements of an XML using C# (.NET)
How to add XML Declaration to an XML document using C# (.NET)
Remove DOCTYPE declaration from XML Files using C#
Monday, June 17, 2013
How to Add/Load XAML Dynamically to RichTextBox Control - Windows Phone Development C#/VB.NET
+Windows Phone Developers are under pressure to release many updates time to time. Please have a look at the sample application that we have been asked to develop. This particular application is about Tiruvannamalai which houses Ashrams of +yogi ram suratkumar , +Ramana Maharshi , +seshadri swamigal and famous for +Girivalam tiruvannamalai .
This place was known to western world, thanks to Paul Brunton. His book - A Search in Secret India: The Classic Work on Seeking a Guru was a best seller
Okay, we have diverted a lot. This particular application requires lot of content. A look at the App should make you understand. Have tried the following method to separate the content from XAML file and link it when necessary
Here is how it works:
- Create Content
- Embed As Resource
- Create Place Holder (RTB)
- Retrieve Resource
- Assign to Control
Create the XAML for the content and save it as a text file and add it to the project's Resource
Ensure that the Resource is BuildAction is set to Embedded Resource. Once that is completed use +C# or +Visual Basic.NET code
the following code to get the XAML assigned to the RichTextBox using
How to Read the External ResourceFile using .NET (C#/VB.NET)
GetManifestResourceStream method is used to get the content from the embedded file as a string
private void GetXAML()
{
RichTextBox rtb = this.PageContent;
string result = "";
using (Stream stream = Assembly.GetExecutingAssembly()
.GetManifestResourceStream("Tiruvannamalai.Resources.PageContentXAML.txt"))
using (StreamReader reader = new StreamReader(stream,System.Text.Encoding.UTF8))
{
result = reader.ReadToEnd();
}
string xamlOP = @"
string xamlMid = result;
string xamlCL = "
";
rtb.Xaml = xamlOP + xamlMid + xamlCL ;
}
The Content is sandwiched between Section tags (here as separate variables) and populated dynamically to the Windows Phone. I tested this using +Nokia Lumia 710 and looks good.
Tuesday, June 4, 2013
Xap packaging failed. Object reference not set to an instance of an object
Subscribe to:
Posts (Atom)