<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>.NET Tips and Tricks &#187; WPF</title>
	<atom:link href="http://blog.themagicsoftware.com/category/wpf/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.themagicsoftware.com</link>
	<description>General tips and tricks for developers about the Microsoft technology stack including the .NET Framework, ASP.NET, ASP.NET MVC, C#.NET, VB.NET, WCF, WPF, WF, Silverlight, XAML, XNA, Windows Phone, Windows 8 and more.</description>
	<lastBuildDate>Sat, 02 Feb 2013 04:54:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5</generator>
		<item>
		<title>Provide value on &#8216;System.Windows.Baml2006.TypeConverterMarkupExtension&#8217; threw an exception.</title>
		<link>http://blog.themagicsoftware.com/2011/07/provide-value-on-system-windows-baml2006-typeconvertermarkupextension-threw-an-exception.html</link>
		<comments>http://blog.themagicsoftware.com/2011/07/provide-value-on-system-windows-baml2006-typeconvertermarkupextension-threw-an-exception.html#comments</comments>
		<pubDate>Tue, 12 Jul 2011 00:38:00 +0000</pubDate>
		<dc:creator>Gerardo Melendrez</dc:creator>
				<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://blog.themagicsoftware.com/2011/07/provide-value-on-system-windows-baml2006-typeconvertermarkupextension-threw-an-exception.html</guid>
		<description><![CDATA[Try changing any .ico images to .png images setup on the ribbon controls. If that does not solve the problem, keep reading. This issue caused me some headaches and turned out to be very simple to resolve (of course, once I knew how to resolve it.) First of all, a little background. I was getting [...]]]></description>
				<content:encoded><![CDATA[<p>Try changing any .ico images to .png images setup on the ribbon controls. If that does not solve the problem, keep reading.</p>
<p>This issue caused me some headaches and turned out to be very simple to resolve (of course, once I knew how to resolve it.)</p>
<p>First of all, a little background. I was getting this error on a WPF application using .NET Framework 4.0, running on a Windows XP machine. The same application worked just fine in Windows 7.</p>
<p>When trying to run the application on the Windows XP box, I was not getting a &#8220;user-friendly&#8221; message, instead my WPF application was crashing right off the bat (as soon as I launched the executable.) By looking at the Event Viewer I was able to find the exception details as shown below, in the Exception Information section. That&#8217;s let&#8217;s friendly, so I went ahead and put any initialization code in a try-catch block and that gave me this:</p>
<p>Provide value on &#8216;System.Windows.Baml2006.TypeConverterMarkupExtension&#8217; threw an exception. Made some progress at least.</p>
<p>I researched that error all over the place, and found out that that error can be caused for a number of reasons, primarily stating that there is a syntax error somewhere in the XAML.Great!!! some more progress.</p>
<p>Some of the problems that I found that may cause that error are:</p>
<p><span class="Apple-style-span" style="color: blue; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;"><span class="Apple-style-span" style="font-size: 14px; white-space: pre;"><span style="color: blue;">&lt;<span style="color: maroon;">Border</span><span style="color: black;">  <span style="color: red;">Margin<span style="color: blue;">=&#8221;1&#8243;</span><span style="color: black;">  <span style="color: red;">BorderBrush<span style="color: blue;">=&#8221;Black&#8221;</span><span style="color: black;">  <span style="color: red;">BorderThickness<span style="color: blue;">=&#8221;"</span><span style="color: black;">  <span style="color: red;">Width<span style="color: blue;">=&#8221;Auto&#8221;/&gt;</span></span></span></span></span></span></span></span></span></span></span></span><br />
<span class="Apple-style-span" style="background-color: white;">N</span>ote the empty BorderThickness property. Putting a value should fix the problem.</p>
<div style="overflow-x: auto; overflow-y: auto; width: 99.5%;">
<pre style="margin: 0em;"><span class="Apple-style-span" style="color: blue; font-family: 'Times New Roman';"><span class="Apple-style-span" style="white-space: normal;"><span style="color: blue;">&lt;<span style="color: maroon;">GradientStop</span><span style="color: black;">  <span style="color: red;">Color<span style="color: blue;">="##FFCBCBCB"</span><span style="color: black;">  <span style="color: red;">Offset<span style="color: blue;">="1"</span><span style="color: black;">  <span style="color: blue;">/&gt;</span></span></span></span></span></span></span></span></span></pre>
<pre style="color: black; margin: 0em;"></pre>
</div>
<p><span class="Apple-style-span" style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; white-space: pre;"><span class="Apple-style-span" style="background-color: white; font-family: 'Times New Roman'; font-size: small; white-space: normal;">Note the dou</span></span><span class="Apple-style-span" style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; white-space: pre;">ble ## in the color property. Removing the extra # should fix the problem.</span></p>
<p><span style="color: blue;">&lt;<span style="color: maroon;">Grid</span><span style="color: black;">  <span style="color: red;">x<span style="color: blue;">:<span style="color: red;">Name<span style="color: blue;">=&#8221;LayoutRoot&#8221;</span><span style="color: black;">  <span style="color: red;">Width<span style="color: blue;">=&#8221;*&#8221;&gt;</span></span></span></span></span></span></span></span><br />
Note the * in the Width property. Either removing that property, or setting it to a number or Auto should fix the problem.</p>
<p><span class="Apple-style-span" style="font-family: monospace;"><span class="Apple-style-span" style="white-space: pre;"><span class="Apple-style-span" style="color: blue;">&lt;</span><span style="color: maroon;">CheckBox</span> <span style="color: black;"><span style="color: red;">Height<span style="color: blue;">=&#8221;"</span><span style="color: black;"> <span style="color: red;">IsChecked<span style="color: blue;">=&#8221;<span style="color: black;">{</span>Binding IsChecked, Mode=TwoWay<span style="color: black;">}</span>&#8220;</span><span style="color: black;"> <span style="color: red;">Width<span style="color: blue;">=&#8221;80&#8243;&gt;</span></span></span></span></span></span></span></span></span></p>
<p>Note the empty Height property, setting a valid height property, or removing the property should fix the issue.</p>
<p>Any how, none of the issues above were my situation so I had to keep looking. Since the message &#8220;Provide value on System.Windows.Baml2006.TypeConverterMarkupExtension threw an exception&#8221; did not tell me much, I went ahead and updated my try-catch block displaying the InnerException error message, as well as the Stack Trace. The inner exception error message obtained was this:</p>
<p>&#8220;The image format is unrecognized.&#8221;</p>
<p>The rest of the story is history!!! <img src='http://blog.themagicsoftware.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>So in summary, try the methods above, as well as changing the image formats, if that fixes your problem (or not) please leave any comments on the area below. Thanks.</p>
<p>Regards,</p>
<p>Gerardo Melendrez<br />
.NET Tips And Tricks</p>
<p>Exception Information from Event Viewer:</p>
<p>Error 1:</p>
<p>Description: The process was terminated due to an unhandled exception.<br />
Exception Info: System.Windows.Markup.XamlParseException<br />
Stack:<br />
at System.Windows.Markup.XamlReader.RewrapException(System.Exception, System.Xaml.IXamlLineInfo, System.Uri)<br />
at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)<br />
at System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri)<br />
at System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)<br />
at System.Windows.Application.LoadComponent(System.Object, System.Uri)<br />
at APT.XBridge.Forms.Aliases.InitializeComponent()<br />
at APT.XBridge.Forms.Aliases..ctor(Boolean, System.String)<br />
at APT.XBridge.MainWindow.btnAliases_Click(System.Object, System.Windows.RoutedEventArgs)<br />
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs)<br />
at System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean)<br />
at System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject, System.Windows.RoutedEventArgs)<br />
at System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs)<br />
at System.Windows.Controls.Primitives.ButtonBase.OnClick()<br />
at System.Windows.Controls.Button.OnClick()<br />
at Microsoft.Windows.Controls.Ribbon.RibbonButton.OnClick()<br />
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(System.Windows.Input.MouseButtonEventArgs)<br />
at System.Windows.UIElement.OnMouseLeftButtonUpThunk(System.Object, System.Windows.Input.MouseButtonEventArgs)<br />
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate, System.Object)<br />
at System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate, System.Object)<br />
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs)<br />
at System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean)<br />
at System.Windows.UIElement.ReRaiseEventAs(System.Windows.DependencyObject, System.Windows.RoutedEventArgs, System.Windows.RoutedEvent)<br />
at System.Windows.UIElement.OnMouseUpThunk(System.Object, System.Windows.Input.MouseButtonEventArgs)<br />
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate, System.Object)<br />
at System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate, System.Object)<br />
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs)<br />
at System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean)<br />
at System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject, System.Windows.RoutedEventArgs)<br />
at System.Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs)<br />
at System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs, Boolean)<br />
at System.Windows.Input.InputManager.ProcessStagingArea()<br />
at System.Windows.Input.InputManager.ProcessInput(System.Windows.Input.InputEventArgs)<br />
at System.Windows.Input.InputProviderSite.ReportInput(System.Windows.Input.InputReport)<br />
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr, System.Windows.Input.InputMode, Int32, System.Windows.Input.RawMouseActions, Int32, Int32, Int32)<br />
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr, MS.Internal.Interop.WindowMessage, IntPtr, IntPtr, Boolean ByRef)<br />
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)<br />
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)<br />
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)<br />
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)<br />
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)<br />
at System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)<br />
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)<br />
at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)<br />
at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)<br />
at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)<br />
at System.Windows.Threading.Dispatcher.Run()<br />
at System.Windows.Application.RunDispatcher(System.Object)<br />
at System.Windows.Application.RunInternal(System.Windows.Window)<br />
at System.Windows.Application.Run(System.Windows.Window)<br />
at System.Windows.Application.Run()<br />
at APT.XBridge.App.Main()</p>
<p>Error 2:<br />
EventType clr20r3, P1 applicationname.exe, P2 1.0.13.11192, P3 4e1b78f5, P4 presentationframework, P5 4.0.0.0, P6 4ba1f8db, P7 a06, P8 46, P9 system.windows.markup.xamlparse, P10 NIL.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.themagicsoftware.com/2011/07/provide-value-on-system-windows-baml2006-typeconvertermarkupextension-threw-an-exception.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to handle when the binding cannot return a value in WPF</title>
		<link>http://blog.themagicsoftware.com/2010/05/how-to-handle-when-the-binding-cannot-return-a-value-in-wpf.html</link>
		<comments>http://blog.themagicsoftware.com/2010/05/how-to-handle-when-the-binding-cannot-return-a-value-in-wpf.html#comments</comments>
		<pubDate>Sun, 16 May 2010 02:44:00 +0000</pubDate>
		<dc:creator>Gerardo Melendrez</dc:creator>
				<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://blog.themagicsoftware.com/2010/05/how-to-handle-when-the-binding-cannot-return-a-value-in-wpf.html</guid>
		<description><![CDATA[Use the FallbackValue property. This is useful, for example when a property does not exist in the class being bound. Example: &#60;TextBlockText=&#8220;{Binding Path=BirthDate, FallbackValue=&#8217;Unknown&#8217;}&#8220; /&#62; &#160;]]></description>
				<content:encoded><![CDATA[<p>Use the FallbackValue property. This is useful, for example when a property does not exist in the class being bound.</p>
<div style="background: white; color: black; font-family: Courier New; font-size: 10pt; margin: 0px;">Example:</div>
<div style="background: white; color: black; font-family: Courier New; font-size: 10pt;">
<div style="margin: 0px;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">TextBlock</span><span style="color: red;">Text</span><span style="color: blue;">=</span>&#8220;<span style="color: blue;">{<span style="color: #a31515;">Binding</span> <span style="color: red;">Path</span>=BirthDate, <span style="color: red;">FallbackValue</span>=&#8217;Unknown&#8217;}</span>&#8220;<span style="color: blue;"> /&gt;</span></div>
<p>&nbsp;</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.themagicsoftware.com/2010/05/how-to-handle-when-the-binding-cannot-return-a-value-in-wpf.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to set a default value when binding to a Null or Nothing value in WPF</title>
		<link>http://blog.themagicsoftware.com/2010/05/how-to-set-a-default-value-when-binding-to-a-null-or-nothing-value-in-wpf.html</link>
		<comments>http://blog.themagicsoftware.com/2010/05/how-to-set-a-default-value-when-binding-to-a-null-or-nothing-value-in-wpf.html#comments</comments>
		<pubDate>Sun, 16 May 2010 02:35:00 +0000</pubDate>
		<dc:creator>Gerardo Melendrez</dc:creator>
				<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://blog.themagicsoftware.com/2010/05/how-to-set-a-default-value-when-binding-to-a-null-or-nothing-value-in-wpf.html</guid>
		<description><![CDATA[Use the TargetNullValue property. Example: &#60;TextBlockText=&#8220;{Binding Path=Age, TargetNullValue=&#8217;Age Unknown&#8217;}&#8220; /&#62; &#160;]]></description>
				<content:encoded><![CDATA[<p>Use the TargetNullValue property.</p>
<div style="background: white; color: black; font-family: Courier New; font-size: 10pt; margin: 0px;">Example:</div>
<div style="background: white; color: black; font-family: Courier New; font-size: 10pt;">
<div style="margin: 0px;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">TextBlock</span><span style="color: red;">Text</span><span style="color: blue;">=</span>&#8220;<span style="color: blue;">{<span style="color: #a31515;">Binding</span> <span style="color: red;">Path</span>=Age, <span style="color: red;">TargetNullValue</span>=&#8217;Age Unknown&#8217;}</span>&#8220;<span style="color: blue;"> /&gt;</span></div>
<p>&nbsp;</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.themagicsoftware.com/2010/05/how-to-set-a-default-value-when-binding-to-a-null-or-nothing-value-in-wpf.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
