0

Im making a flash card like app in xaml, I created a textblock and was wondering how can I call text in a seperate .txt file so I dont have to write out the whole definition in the same page.

<Textblock Height="150" TextWrapping="Wrap" Text="**how do i link this**">

Thanks

iOSecure
  • 232
  • 6
  • 18
  • 1
    Do you mean how do you link some text to the textblocks text parameter?. If so I would suggest you look at Binding on MSDN. http://msdn.microsoft.com/en-us/library/windowsphone/develop/cc278072(v=vs.105).aspx – JayDev Jul 10 '14 at 13:56

1 Answers1

1

The easiest method would be to do this in the code behind. Either at page_load or triggered some other way. I think your question is answered here: Windows Phone 8 - reading and writing in an existing txt file in the project

Using this method, I'd store your flash cards in the Assets folder and read them from there.

For your case, you would want to name your Textblock and then set the text from your code behind.

XAML:

<Textblock x:Name="tbFlashCard" Height="150" TextWrapping="Wrap" Text="**how do i link this**">

Modified code from other post:

tbFlashCard.Text = FileHelper.ReadFile(@"Assets\MyTextFile.txt");
Community
  • 1
  • 1
Cory
  • 1,794
  • 12
  • 21