Project: Dynamic.Xaml

Load XAML dynamically and use binding due to MVVM pattern:
void Main()
{
	var context = new ParserContext();
	context.XmlnsDictionary.Add("", "http://schemas.microsoft.com/winfx/2006/xaml/presentation");
	
	var xaml = "<TextBox Text=\"{Binding Name, Mode = OneWay}\"></TextBox>";
	var element = (FrameworkElement)XamlReader.Parse(xaml, context);
	element.DataContext = new { Name = "Test" };
	
	PanelManager.StackWpfElement(element);
}

Last edited Mar 21, 2012 at 10:41 PM by teoarch, version 1

Comments

heilmannseder Jul 27, 2015 at 2:44 PM 
You need to add References (F4) to PresentationCore.dll and PresentationFramework.dll
and also the using "System.Windows.Markup "