+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.
XamlFormatProvider C# class to import and export content of KetticRichTextBox to/from XAML documents
ReplyDelete