Questions tagged [xamlreader]

XamlReader Class reads XAML input and creates an object graph, using the WPF default XAML reader and an associated XAML object writer.

XamlReader supports the following primary scenarios:

  1. Cloning/object factory: Without additional mechanisms, a reference type generally cannot be included in more than one position in a WPF object tree. (Examples of additional mechanisms that offer support for sharing or re-use in WPF include objects that are based on Freezable, or support for commonly shareable objects such as Brush that are referenced as an item from a ResourceDictionary.) One way to clone an object that is already in the object tree is to serialize the object using XamlWriter.Save. You then use the serialized string as input for a call to Load, with a stream or XmlReader as an intermediary.

  2. Constructing objects based on just-in-time information: There are often other ways to have late-binding or user-supplied input change the state of existing objects. For example you could use the same value to set more than one property, or use data binding. But if you have a scenario where even the type of object to create is only determinable at run time or with user interaction, then creating such an object by building up a string for Load input is often a useful technique.

  3. Using existing resource techniques: The Stream type is used frequently in other frameworks or technologies for transferring data or objects across application boundaries or for similar situations. You can then use the Stream techniques to store or obtain XAML-formatted data that you eventually use to create an object as part of your application.

  4. Fixed documents: Your application might load local or downloaded XPS documents for inclusion in a WPF application object tree and UI.

Read more

108 questions
0
votes
1 answer

Transform image using XAML and generate new image

I have a ASP.NET MVC website. I have a "flat" PNG image in my project that I need to transform. I think that I can use XAML for it. Steps : Create a XAML UserControl (or other) that transform the image adding a 3d effect for example Use a…
user3544117
  • 587
  • 4
  • 9
  • 25
0
votes
1 answer

FlowDocument and XamlReader x:Class

In my MainWindow I have a FlowDocumentScrollViewer binding its property Document to a FlowDocument in my MainViewModel. This document is loaded from an external xaml file store on a remote computer. Currently I'm able to load this document properly…
Bastien
  • 994
  • 11
  • 25
0
votes
1 answer

How to access relatively places text files in folders below a Silverlight .xap file?

In a WPF application, I load in xaml files with the xamlreader by finding the current directory like this: public static string GetApplicationDirectory() { return System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } so I…
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
0
votes
1 answer
0
votes
2 answers

Is it possible to use XamlReader from a XAML file to load in a block of XAML text?

I use the following DataTemplate in many controls:
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
0
votes
2 answers

ScrollViewer is sizing over everything no matter what I do. :(

All, I am a novice to WPF and this seems to be a problem that a lot of people struggle with. I have put together the following piece of XAML which is then programmatically loaded into code. ONLY the template is used and is applied to a…
unwrittenrainbow
  • 473
  • 1
  • 7
  • 15
0
votes
1 answer

c#.net XamlReader.Parse method not available/missing?

I am developing a WCF REST web service in c# (.net Framework 3.5, using Visual Studio 2010) which pulls rows from an MSSQL DB. One of the columns that gets pulled is type "nvarchar(max)" and always contains a XAML formatted text string who's root…
Tommy
  • 176
  • 1
  • 2
  • 17
0
votes
0 answers

Exporting app interface as XAML: is XAML compiled?

I'm working on a Windows Phone 8 app and would like to not only be able to load new XAML into my app using XamlReader.Load, but to also read my app's current XAML and be able to parse and/or output it. How much of a Windows Phone app's XAML is BAML…
Eric Dand
  • 1,106
  • 13
  • 37
0
votes
1 answer

XamlReader official code snippet throwing exception for me

I'm building a Windows 8 app, and want to parse some XAML from a web service to put in a RichTextBlock. I'm trying to use XamlReader to use this, but this code from Microsoft's documentation is throwing an exception in my environment. string xaml =…
user460847
  • 1,578
  • 6
  • 25
  • 43
0
votes
1 answer

WPF XamlReader.Parse Dynamic UI xml Namespaces

I've a dynamic WPF UI wich is described in xaml. The xaml can be seen below. My Problem is that my Custom namespaces aren't resolved automatically, To get the xaml loaded I have to set each assembly with its namespace to the parser context like…
Boas Enkler
  • 12,264
  • 16
  • 69
  • 143
0
votes
1 answer

Error using XamlReader.Load() to create Prism Regions from file?

I'm using Silverlight 5 with Prism and MEF. I am trying to replace my shell at runtime by reading a XAML file, create an UIElement from it and replace the old shell's content with the new UIElement. I am using XamlReader.Load() for this. This works,…
Phasma
  • 232
  • 2
  • 16
0
votes
1 answer

Setting Canvas.Left on a UserControl parsed via XamlReader

I've played a bit with WPF. What I want to do is drag a custom control from a template palette window to the canvas of another window and create a clone of that custom control there. This is very much like what you would see in Visio. In order to…
Chris
  • 3,192
  • 4
  • 30
  • 43
0
votes
1 answer

XamlReader.Parse and RadioButton GroupName

I have very strange problem. Is there any possibility to have these two controls radio and newRadio have property IsChecked == true. Before code in line 6 is executed radio.IsChecked == true, but after executing code in line 6 radio.IsChecked ==…
torpederos
  • 761
  • 12
  • 31
0
votes
1 answer

different behavior of xamlreader

What's the difference between XamlReader in WPF and WP7? I've got XAML file and I want to load it dynamically in my wp7 app. I'm using XamlReader.Load() function. For test purposes I've created simple app in WPF and file loaded perfectly. In wp7…
fl4izdn4g
  • 35
  • 1
  • 6
0
votes
2 answers

WPF When clicking on the different Treeviewitem the related part of the text in TextBlock gets highlighted

I have a Treeview and a Textblock and both of them populated with the data from the backend by using MVVM. The TextBlock contains the formatted hex string (it looks like this: 0000: ad be e6 00 25 00 00 00 9e 7b 3b 04 40 01 db …
L Z
  • 1
  • 1