コード例 #1
0
 /// <summary>
 /// Replaces the Key Value Pairs in the Xaml source, this is an other way of data 
 /// binding, but I prefere the build-in way.
 /// </summary>
 /// <param name="xamlFileStream">The xaml file stream.</param>
 /// <returns></returns>
 private Stream ReplaceStringsInXaml(Stream xamlFileStream) {
     string rawXamlText;
     xamlFileStream.Seek(0, SeekOrigin.Begin);
     using (StreamReader streamReader = new StreamReader(xamlFileStream)) {
         rawXamlText = streamReader.ReadToEnd();
     }
     foreach (KeyValuePair<string, string> keyValuePair in _stringReplacement) {
         rawXamlText = rawXamlText.Replace(keyValuePair.Key, keyValuePair.Value);
     }
     return new MemoryStream(new UTF8Encoding().GetBytes(rawXamlText));
 }