Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I have this code which reads text files in my app folder and displayed it in a messagebox,
whenever the user clicks an item in a list and it's working fine.

CustomMessageBox cmb;
private void Day1(object sender, System.Windows.Input.GestureEventArgs e)
{
// create new Stack panel
StackPanel sp = new StackPanel() { Orientation = System.Windows.Controls.Orientation.Vertical };

//get policy text from file
string devotion = getDevotion335();

//Create new label
TextBlock tb = new TextBlock()
{
Text = devotion,
TextWrapping = TextWrapping.Wrap,
FontSize = 20,

};

//Create new Scroll viewer
ScrollViewer sv = new ScrollViewer()
{
VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
Height = 700,
};

// add texblock in scroll viewer
sv.Content = tb;

//Add the controls to stack panel
sp.Children.Add(sv);

cmb = new CustomMessageBox()
{
// Set its content
Content = sp,
Opacity = 15.0,


// Left button of message box Button
LeftButtonContent = "Back",


};

//Show the message box...
cmb.Show();
}

private string getDevotion335()
{
using (StreamReader s = new StreamReader("Devotions/Devotion335.txt"))
{
return s.ReadToEnd();
}
}

Instead of displaying it in a messagebox i will like it to be displayed in a xaml page.
What are major changes i need to make to the code kindly help

Thank you in advance and reply soon
Posted
Comments
Sergey Alexandrovich Kryukov 20-May-15 13:58pm    
What is that supposed to mean: "display in XAML"? How is that related to "display in MessageBox"?
—SA

1 solution

Place a textbox on your screen. Name it as something, I'll call it txtBox

Whenever you want to display your data you can do add the following line to your code

C#
//some code

txtBox.Text = getDevotion335();

//some other code
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900