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
0 answers

Powershell - Unable to find type [Windows.Markup.XamlReader]

I'm working on a script with a GUI controlled by a PS class. I created a XAML file in VS and am trying to import the XAML. There is a method that imports, formats and loads the xaml file. I have a similar script, that uses a XAML file too and I have…
Nikolai
  • 9
  • 1
0
votes
1 answer

Weird Behaviour of XamlReader.Load() function

I want to create wpf controls using xml literals and xamlreader.load(). But I'm stuck trying to load xml literals containing property element notation because it keeps throwing the XamlParseException "Cannot set unknown member". Details: This…
0
votes
1 answer

How can I deserialize and load serialized XAML UI Elements?

My application has a feature which involves saving some UI Elements that have been creating in order to recreate them the next time the user launches the application. To do so, it saves The UI Element Object using the XamlWriter.Save function, and…
BBonless
  • 97
  • 7
0
votes
1 answer

WPF - cannot parse TextBlock element from string

I'm new in WPF I need to get string param, create an UIElement and attach it to the view. Parsing the element from the string is failed, I don't know why. Here is the code: public void addElementToView(string str) { object obj =…
user5260143
  • 1,048
  • 2
  • 12
  • 36
0
votes
4 answers

Working with V.V.Big XAML file

Have you ever tried working with a XAML file which contains thousand tons of line of code. (More specifically Drawing Brushes for whole application in my case). This file is of 20+ MB size. Whenever i try to add/edit anything in this, Visual Studio…
Rohit
  • 6,365
  • 14
  • 59
  • 90
0
votes
0 answers

Trying to load Xaml element(s) at runtime using Xamlreader

This is my C#, it appears to load the Xaml just fine, all the children are in R1C3Viewbox as well as the data they contain. But nothing displays on screen. ParserContext context = new ParserContext(); context.XmlnsDictionary.Add("",…
0
votes
0 answers

How to load XAML with images using XamlReader.Load method?

Is it possible to load XAML file with images from stream into WPF application? And how to store this images in the files? I've tried part, but XamlReader.Load method can't process it. XAML Code:
0
votes
1 answer

How to access a control added from C# by name

I have added a content Control containing a telerik Chart which i have named bob. I have used xamlReader.parse to build the content control and then place it onto a canvas. I now want to access the the chart called bob to set it's values. var…
Pomster
  • 14,567
  • 55
  • 128
  • 204
0
votes
1 answer

Why does data binding on a dynamically loaded control break?

Currently I'm designing an application that should at one point be able to create a report from a Xaml template File using Data Binding (involving a FlowDocument). The idea was to simply convert a dynamically loaded control via BlockUIContainer to…
Adwaenyth
  • 2,020
  • 12
  • 24
0
votes
0 answers

Add textblock dynamically in c#

My code belows throw a null reference exception // Create a string String sb = ""; // Create…
Techies
  • 29
  • 4
0
votes
1 answer

Is it possible to use XAML for my own ideas / framework?

Do you know if it would be possible to create a framework myself in C# that utilizes the good things that XAML offers, such as dependency properties and data binding? Or would I have to create everything from scratch myself?
0
votes
2 answers

XamlReader.Load is throwing System.Windows.Markup.XamlParseException

What could be wrong with the following:
Abbas
  • 3,872
  • 6
  • 36
  • 63
0
votes
2 answers

Silverlight - XamlParseException The type 'Type' was not found

The type 'Type' was not found. [Line: 7 Position: 21] I'm trying to dynamically generate a datatemplate. it works fine, but if I include this attribute, I get the above exception. Width="{Binding Path=ActualWidth,RelativeSource={RelativeSource…
Slime recipe
  • 2,223
  • 3
  • 32
  • 49
0
votes
0 answers

Windows.UI.Xaml.Markup.XamlParseException while trying to locate a string

I'm following this tutorial to create my first Windows app. I'm at step 3, and if I try to run the applications I get a Windows.UI.Xaml.Markup.XamlParseException here Since…
andrew
  • 3,879
  • 4
  • 25
  • 43
0
votes
1 answer

Load dynamically a ResourceDictionnary

I'm having some issues. I want my app to load a ResourceDictonnary dynamically in app.xaml.cs. This is my code for the moment : ResourceDictionary theme = XamlReader.Load(???); Resources.MergedDictionaries.Add(theme); The problem is, how can I get…
Floc
  • 668
  • 8
  • 16