<?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>Biggle&#039;s Blog &#187; WPF</title>
	<atom:link href="http://www.biggle.de/blog/tag/wpf/feed" rel="self" type="application/rss+xml" />
	<link>http://www.biggle.de/blog</link>
	<description>Web- und Software Development</description>
	<lastBuildDate>Tue, 07 Feb 2012 13:08:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>DataBindings debuggen &#8211; WPF</title>
		<link>http://www.biggle.de/blog/databindings-debuggen-wpf</link>
		<comments>http://www.biggle.de/blog/databindings-debuggen-wpf#comments</comments>
		<pubDate>Sun, 24 Jul 2011 12:21:33 +0000</pubDate>
		<dc:creator>Mario Priebe</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.biggle.de/blog/databindings-debuggen-wpf</guid>
		<description><![CDATA[Beim DataBinding ist es nicht immer einfach festzustellen, warum denn nun ein Wert nicht angezeigt wird. Die Fehlersuche zeigt sich mitunter, gerade auch in immer größer werdenden Projekten, als äußerst schwierig. Das liegt daran, das im DataBinding keine Exception geworfen werden, wenn hier ein Element, eine Property, oder ein Path nicht gefunden wird. Ein paar [...]]]></description>
			<content:encoded><![CDATA[<p>Beim <strong>DataBinding</strong> ist es nicht immer einfach festzustellen, warum denn nun ein Wert nicht angezeigt wird. Die Fehlersuche zeigt sich mitunter, gerade auch in immer größer werdenden Projekten, als äußerst schwierig. </p>
<p>Das liegt daran, das im DataBinding keine Exception geworfen werden, wenn hier ein Element, eine Property, oder ein Path nicht gefunden wird.</p>
<p>Ein paar kleine Tricks können Abhilfe und für ein stressfreies Wochenende sorgen.</p>
<h2>Tipp 1: Ausgabefenster</h2>
<p>Lässt man sich beim <strong>Debuggen</strong> das Ausgabefenster von Visual Studio anzeigen, kann man diesem schon wertvolle Informationen entlocken.</p>
<p>Eine Fehlermeldung könnte z.B. wie folgt aussehen:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:c084c814-cc53-47d3-93a6-a8625a21d9ef" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">System.Windows.Data Error: </span><span style="color: #800080;">40</span><span style="color: #000000;"> : BindingExpression path error: </span><span style="color: #800000;">'</span><span style="color: #800000;">Mesage</span><span style="color: #800000;">'</span><span style="color: #000000;"> property not found on </span><span style="color: #800000;">'</span><span style="color: #800000;">object</span><span style="color: #800000;">'</span><span style="color: #000000;"> </span><span style="color: #800000;">''</span><span style="color: #000000;">MainWindow</span><span style="color: #800000;">'</span><span style="color: #800000;"> (Name=</span><span style="color: #800000;">''</span><span style="color: #800000;">)</span><span style="color: #800000;">'</span><span style="color: #000000;">. BindingExpression:Path</span><span style="color: #000000;">=</span><span style="color: #000000;">Mesage; DataItem</span><span style="color: #000000;">=</span><span style="color: #800000;">'</span><span style="color: #800000;">MainWindow</span><span style="color: #800000;">'</span><span style="color: #000000;"> (Name</span><span style="color: #000000;">=</span><span style="color: #800000;">''</span><span style="color: #000000;">); target element </span><span style="color: #0000FF;">is</span><span style="color: #000000;"> </span><span style="color: #800000;">'</span><span style="color: #800000;">TextBox</span><span style="color: #800000;">'</span><span style="color: #000000;"> (Name</span><span style="color: #000000;">=</span><span style="color: #800000;">''</span><span style="color: #000000;">); target property </span><span style="color: #0000FF;">is</span><span style="color: #000000;"> </span><span style="color: #800000;">'</span><span style="color: #800000;">Text</span><span style="color: #800000;">'</span><span style="color: #000000;"> (type </span><span style="color: #800000;">'</span><span style="color: #800000;">String</span><span style="color: #800000;">'</span><span style="color: #000000;">)</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Hier finde ich dann, das ich mich bei der Property “Message” verschrieben habe (“Mesage”).</p>
<p>Um das Ausgabefenster anzuzeigen, geht man unter <strong>Ansicht</strong> &gt; <strong>Ausgabe</strong> oder zeigt dieses über die Tastenkombination <strong>CTRL+W+O</strong> an. Man muss hier aber darauf achten, dass man sich bereits im Debugging befindet.</p>
<p>Vorher sollte man überprüfen ob die Einstellungen in Visual Studio richtig sind.</p>
<p>Dazu geht man nach <strong>Extras &gt; Optionen &gt; Debugging &gt; Ausgabefenster</strong> und wählt hier unter WPF-Ablaufverfolgung im DropDown “<strong>DataBinding</strong>” die Option “<strong>Alle</strong>”</p>
<p><a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGUvYmxvZy93cC1jb250ZW50L3VwbG9hZHMvMjAxMS8wNy9pbWFnZTMucG5n"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.biggle.de/blog/wp-content/uploads/2011/07/image_thumb3.png" width="504" height="314" /></a></p>
<p>&#160;</p>
<h2>Tipp 2: PresentationTraceSources</h2>
<p>Wem die Informationen in der Ausgabe nicht ausreichen, kann sein Control um weitere, ausführlichere Informationen erweitern. </p>
<p>Hierzu referenziert man auf den Namespace <strong>System.Diagnostics</strong> aus der Assembly <strong>WindowsBase</strong></p>
<p><a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGUvYmxvZy93cC1jb250ZW50L3VwbG9hZHMvMjAxMS8wNy9pbWFnZTQucG5n"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.biggle.de/blog/wp-content/uploads/2011/07/image_thumb4.png" width="504" height="231" /></a></p>
<p>&#160;</p>
<p>Anschließend erweitert man sein Binding um das <strong>AttachedProperty</strong> <strong>TraceLevel</strong> aus der Klasse <strong>PresentationTraceSources</strong> und dieses um den Wert <strong>High</strong>:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:e54f6dab-ef3c-4c15-bf73-30c5b66214ad" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">&lt;</span><span style="color: #000000;">TextBox Text</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">{Binding Mesage, debugging:PresentationTraceSources.TraceLevel=High}</span><span style="color: #800000;">"</span><span style="color: #000000;">  </span><span style="color: #000000;">/&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Hier bekommt man dann richtig viele Informationen zu einem Binding, die ich hier auszugsweise nur als Grafik zeigen möchte:</p>
<p><a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGUvYmxvZy93cC1jb250ZW50L3VwbG9hZHMvMjAxMS8wNy9pbWFnZTUucG5n"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.biggle.de/blog/wp-content/uploads/2011/07/image_thumb5.png" width="504" height="223" /></a></p>
<p>Mögliche Werte in TraceLevel können sein: High, Low, Medium und None.</p>
<h2>Tipp 3: IValueConverter</h2>
<p>Nun, es kommt vor, dass obwohl die Properties richtig definiert sind, immer noch nicht das angezeigt wird, was man eigentlich erwartet. Hier kommt die dritte Möglichkeit ins Spiel. </p>
<p>Es wäre doch toll, wenn man irgendwie einen BreakPoint irgendwo setzen könnte um nach gewohnter Manier zu debuggen. Ja, auch das ist möglich.</p>
<p>Hierzu definiert man sich einen Converter, der lediglich den Value durchreicht:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:454b9518-2ad8-497e-b1b1-bdaa58de3778" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">class</span><span style="color: #000000;"> DebuggingConverter : IValueConverter
{
    </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">object</span><span style="color: #000000;"> Convert(</span><span style="color: #0000FF;">object</span><span style="color: #000000;"> value, Type targetType, </span><span style="color: #0000FF;">object</span><span style="color: #000000;"> parameter, System.Globalization.CultureInfo culture)
    {
        </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> value;
    }

    </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">object</span><span style="color: #000000;"> ConvertBack(</span><span style="color: #0000FF;">object</span><span style="color: #000000;"> value, Type targetType, </span><span style="color: #0000FF;">object</span><span style="color: #000000;"> parameter, System.Globalization.CultureInfo culture)
    {
        </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> value;
    }
}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Nun referenziert man den Namespace zum Converter und in den Resources des Elements wird der Converter bekannt gemacht:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:e5247a9f-1d97-49e0-95b6-90180f4a4474" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">xmlns:converter</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">clr-namespace:Debugging</span><span style="color: #800000;">"</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:923db1d9-42f4-484e-b28b-a32e1f2cc344" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">&lt;</span><span style="color: #000000;">Grid.Resources</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">
    </span><span style="color: #000000;">&lt;</span><span style="color: #000000;">converter:DebuggingConverter x:Key</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">debugger</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">/&gt;</span><span style="color: #000000;">
</span><span style="color: #000000;">&lt;/</span><span style="color: #000000;">Grid.Resources</span><span style="color: #000000;">&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Im Binding wird der Converter dann noch definiert</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:f63758ae-a5d8-4cc1-9142-c0a85ba24537" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">&lt;</span><span style="color: #000000;">TextBox Text</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">{Binding Message, Converter={StaticResource debugger}}</span><span style="color: #800000;">"</span><span style="color: #000000;">  </span><span style="color: #000000;">/&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Jetzt setze ich meine BreakPoints im <strong>Convert</strong> oder beim TwoWay-Binding auch im <strong>ConvertBack</strong> und kann mir den Wert genauer anschauen.</p>
<p>&#160;</p>
<p>Viel Spaß beim entwickeln : )</p>
<hr /><p style="float:right; font-size:0.9em;">Dieser Beitrag stammt von <a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGU=">Mario Priebe</a>.</p> <img src="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=6572" width="1" height="1" style="display: none;" /><h2  class="related_post_title">Ähnliche Beiträge</h2><ul class="related_post"><li>23. Juli 2011 -- <a href="http://www.biggle.de/blog/gemeinsamen-validation-style-fr-controls-wpf" title="Gemeinsamen Validation Style f&uuml;r Controls &#8211; WPF">Gemeinsamen Validation Style f&uuml;r Controls &#8211; WPF</a></li><li>25. Juni 2011 -- <a href="http://www.biggle.de/blog/enumeration-in-einer-combobox-darstellen-wpf-quicky" title="Enumeration in einer ComboBox darstellen &#8211; WPF Quicky">Enumeration in einer ComboBox darstellen &#8211; WPF Quicky</a></li><li>15. März 2011 -- <a href="http://www.biggle.de/blog/cookies-in-einer-wpf-applikation" title="Cookies in einer WPF Applikation">Cookies in einer WPF Applikation</a></li><li>6. März 2011 -- <a href="http://www.biggle.de/blog/multibinding-die-zweite" title="MultiBinding die Zweite">MultiBinding die Zweite</a></li><li>14. Februar 2011 -- <a href="http://www.biggle.de/blog/doppelklick-im-datagrid-abfangen-wpf-quicky" title="Doppelklick im DataGrid abfangen &#8211; WPF Quicky">Doppelklick im DataGrid abfangen &#8211; WPF Quicky</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.biggle.de/blog/databindings-debuggen-wpf/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Gemeinsamen Validation Style f&#252;r Controls &#8211; WPF</title>
		<link>http://www.biggle.de/blog/gemeinsamen-validation-style-fr-controls-wpf</link>
		<comments>http://www.biggle.de/blog/gemeinsamen-validation-style-fr-controls-wpf#comments</comments>
		<pubDate>Sat, 23 Jul 2011 13:42:35 +0000</pubDate>
		<dc:creator>Mario Priebe</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.biggle.de/blog/gemeinsamen-validation-style-fr-controls-wpf</guid>
		<description><![CDATA[Um einen gemeinsamen Style für Validierungsfehler in der WPF zu verwenden, definiert man einen Style für den TargetType Control und vergibt diesen einen Key. &#60;Style x:Key="validationTriggerBase" TargetType="Control"&#62; &#60;Style.Triggers&#62; &#60;Trigger Property="Validation.HasError" Value="true"&#62; &#60;Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent }" /&#62; &#60;/Trigger&#62; &#60;/Style.Triggers&#62; &#60;/Style&#62; &#60;Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource validationTriggerBase}" /&#62; Viel Spaß beim entwickeln : ) Dieser [...]]]></description>
			<content:encoded><![CDATA[<p>Um einen gemeinsamen Style für Validierungsfehler in der WPF zu verwenden, definiert man einen Style für den TargetType Control und vergibt diesen einen Key.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:8dec15c3-d4b0-4687-93b7-c579bbcda6d8" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">&lt;</span><span style="color: #000000;">Style x:Key</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">validationTriggerBase</span><span style="color: #800000;">"</span><span style="color: #000000;"> TargetType</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">Control</span><span style="color: #800000;">"</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">
    </span><span style="color: #000000;">&lt;</span><span style="color: #000000;">Style.Triggers</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">
        </span><span style="color: #000000;">&lt;</span><span style="color: #000000;">Trigger Property</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">Validation.HasError</span><span style="color: #800000;">"</span><span style="color: #000000;"> Value</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">true</span><span style="color: #800000;">"</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">
            </span><span style="color: #000000;">&lt;</span><span style="color: #000000;">Setter Property</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">ToolTip</span><span style="color: #800000;">"</span><span style="color: #000000;"> Value</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent   }</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">/&gt;</span><span style="color: #000000;">
        </span><span style="color: #000000;">&lt;/</span><span style="color: #000000;">Trigger</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">
    </span><span style="color: #000000;">&lt;/</span><span style="color: #000000;">Style.Triggers</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">
</span><span style="color: #000000;">&lt;/</span><span style="color: #000000;">Style</span><span style="color: #000000;">&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Im Anschluss, kann man einzelne Controls diesen Style zuweisen:</p>
<p><div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:e0d41a29-4e6f-4969-af3e-0a2e19c0c20d" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">&lt;</span><span style="color: #000000;">Style TargetType</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">{x:Type DatePicker}</span><span style="color: #800000;">"</span><span style="color: #000000;"> BasedOn</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">{StaticResource validationTriggerBase}</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">/&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
</p>
<p><a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGUvYmxvZy93cC1jb250ZW50L3VwbG9hZHMvMjAxMS8wNy9pbWFnZTEucG5n"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.biggle.de/blog/wp-content/uploads/2011/07/image_thumb1.png" width="244" height="75" /></a></p>
<p><div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:c0e96b0f-9269-4518-9d0a-95de41e07d1b" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">&lt;</span><span style="color: #000000;">Style TargetType</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">{x:Type TextBox}</span><span style="color: #800000;">"</span><span style="color: #000000;"> BasedOn</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">{StaticResource validationTriggerBase}</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">/&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
</p>
<p><a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGUvYmxvZy93cC1jb250ZW50L3VwbG9hZHMvMjAxMS8wNy9pbWFnZTIucG5n"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.biggle.de/blog/wp-content/uploads/2011/07/image_thumb2.png" width="244" height="58" /></a></p>
<p>Nicht vergessen, das bindende Control muss <em>ValidatesOnDataErrors=True</em> aufrufen.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:d6065793-78f1-4a3e-b89c-4ce4ef0e1eac" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">&lt;</span><span style="color: #000000;">StackPanel Width</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">250</span><span style="color: #800000;">"</span><span style="color: #000000;"> HorizontalAlignment</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">Center</span><span style="color: #800000;">"</span><span style="color: #000000;"> DataContext</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">{StaticResource Person}</span><span style="color: #800000;">"</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">
    </span><span style="color: #000000;">&lt;</span><span style="color: #000000;">TextBox Text</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">{Binding Name, ValidatesOnDataErrors=True, </span><span style="color: #800000;">
</span><span style="color: #000000;">        UpdateSourceTrigger</span><span style="color: #000000;">=</span><span style="color: #000000;">PropertyChanged}</span><span style="color: #800000;">"</span><span style="color: #800000;"> /&gt;</span><span style="color: #800000;">
</span><span style="color: #000000;">
    </span><span style="color: #000000;">&lt;</span><span style="color: #000000;">DatePicker SelectedDate</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">{Binding Birthday, StringFormat=dd.mm.yyyy, </span><span style="color: #800000;">
</span><span style="color: #000000;">        ValidatesOnDataErrors</span><span style="color: #000000;">=</span><span style="color: #000000;">True,
        UpdateSourceTrigger</span><span style="color: #000000;">=</span><span style="color: #000000;">PropertyChanged, Converter</span><span style="color: #000000;">=</span><span style="color: #000000;">{StaticResource conv}}</span><span style="color: #800000;">"</span><span style="color: #800000;"> /&gt;</span><span style="color: #800000;">
</span><span style="color: #000000;">&lt;/</span><span style="color: #000000;">StackPanel</span><span style="color: #000000;">&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Viel Spaß beim entwickeln : )</p>
<hr /><p style="float:right; font-size:0.9em;">Dieser Beitrag stammt von <a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGU=">Mario Priebe</a>.</p> <img src="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=6565" width="1" height="1" style="display: none;" /><h2  class="related_post_title">Ähnliche Beiträge</h2><ul class="related_post"><li>24. Juli 2011 -- <a href="http://www.biggle.de/blog/databindings-debuggen-wpf" title="DataBindings debuggen &#8211; WPF">DataBindings debuggen &#8211; WPF</a></li><li>25. Juni 2011 -- <a href="http://www.biggle.de/blog/enumeration-in-einer-combobox-darstellen-wpf-quicky" title="Enumeration in einer ComboBox darstellen &#8211; WPF Quicky">Enumeration in einer ComboBox darstellen &#8211; WPF Quicky</a></li><li>15. März 2011 -- <a href="http://www.biggle.de/blog/cookies-in-einer-wpf-applikation" title="Cookies in einer WPF Applikation">Cookies in einer WPF Applikation</a></li><li>6. März 2011 -- <a href="http://www.biggle.de/blog/multibinding-die-zweite" title="MultiBinding die Zweite">MultiBinding die Zweite</a></li><li>14. Februar 2011 -- <a href="http://www.biggle.de/blog/doppelklick-im-datagrid-abfangen-wpf-quicky" title="Doppelklick im DataGrid abfangen &#8211; WPF Quicky">Doppelklick im DataGrid abfangen &#8211; WPF Quicky</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.biggle.de/blog/gemeinsamen-validation-style-fr-controls-wpf/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enumeration in einer ComboBox darstellen &#8211; WPF Quicky</title>
		<link>http://www.biggle.de/blog/enumeration-in-einer-combobox-darstellen-wpf-quicky</link>
		<comments>http://www.biggle.de/blog/enumeration-in-einer-combobox-darstellen-wpf-quicky#comments</comments>
		<pubDate>Sat, 25 Jun 2011 05:24:43 +0000</pubDate>
		<dc:creator>Mario Priebe</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[Tipps]]></category>

		<guid isPermaLink="false">http://www.biggle.de/blog/enumeration-in-einer-combobox-darstellen-wpf-quicky</guid>
		<description><![CDATA[Um eine Aufzählung unter WPF in einer ComboBox darzustellen, brauch man nicht wirklich viel. Mit der Methode GetValues() aus der Klasse Enum, bekommt man einen Array mit den Konstanten aus der Aufzählung zurück. &#60;ComboBox ItemsSource="{Binding AutoCompleteFilters}" SelectedItem="{Binding SelectedFilterMode}" /&#62; Viel Spaß beim entwickeln : ) Dieser Beitrag stammt von Mario Priebe. Ähnliche Beiträge31. Juli 2011 [...]]]></description>
			<content:encoded><![CDATA[<p>Um eine Aufzählung unter WPF in einer ComboBox darzustellen, brauch man nicht wirklich viel. </p>
<p>Mit der Methode <strong>GetValues</strong>() aus der Klasse <strong><a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL21zZG4ubWljcm9zb2Z0LmNvbS9lbi11cy9saWJyYXJ5L3N5c3RlbS5lbnVtLmFzcHg=" target=\"_blank\">Enum</a></strong>, bekommt man einen Array mit den Konstanten aus der Aufzählung zurück.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:87f9b72d-3f3b-4a6a-8fb3-996d70438064" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">&lt;</span><span style="color: #000000;">ComboBox ItemsSource</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">{Binding AutoCompleteFilters}</span><span style="color: #800000;">"</span><span style="color: #000000;"> SelectedItem</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">{Binding SelectedFilterMode}</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">/&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:03122e71-7e5a-469e-883a-3bdaed189929" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #0000FF;">public</span><span style="color: #000000;"> List</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">AutoCompleteFilterMode</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> AutoCompleteFilters { </span><span style="color: #0000FF;">get</span><span style="color: #000000;">; </span><span style="color: #0000FF;">set</span><span style="color: #000000;">; }

</span><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> SetAutoCompleteFilters()
{
    Array values </span><span style="color: #000000;">=</span><span style="color: #000000;"> Enum.GetValues((</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(AutoCompleteFilterMode)));

    AutoCompleteFilters </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> List</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">AutoCompleteFilterMode</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">();
    </span><span style="color: #0000FF;">foreach</span><span style="color: #000000;"> (AutoCompleteFilterMode value </span><span style="color: #0000FF;">in</span><span style="color: #000000;"> values)
    {
        AutoCompleteFilters.Add(value);
    }
}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p><a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGUvYmxvZy93cC1jb250ZW50L3VwbG9hZHMvMjAxMS8wNi9pbWFnZS5wbmc="><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.biggle.de/blog/wp-content/uploads/2011/06/image_thumb.png" width="360" height="330" /></a></p>
<p>Viel Spaß beim entwickeln : )</p>
<hr /><p style="float:right; font-size:0.9em;">Dieser Beitrag stammt von <a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGU=">Mario Priebe</a>.</p> <img src="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=6503" width="1" height="1" style="display: none;" /><h2  class="related_post_title">Ähnliche Beiträge</h2><ul class="related_post"><li>31. Juli 2011 -- <a href="http://www.biggle.de/blog/gottmodus-in-windows-7-aktivieren" title="Gottmodus in Windows 7 aktivieren">Gottmodus in Windows 7 aktivieren</a></li><li>24. Juli 2011 -- <a href="http://www.biggle.de/blog/databindings-debuggen-wpf" title="DataBindings debuggen &#8211; WPF">DataBindings debuggen &#8211; WPF</a></li><li>23. Juli 2011 -- <a href="http://www.biggle.de/blog/gemeinsamen-validation-style-fr-controls-wpf" title="Gemeinsamen Validation Style f&uuml;r Controls &#8211; WPF">Gemeinsamen Validation Style f&uuml;r Controls &#8211; WPF</a></li><li>4. Juli 2011 -- <a href="http://www.biggle.de/blog/neuer-ordner-im-projekt-per-hotkey" title="Neuer Ordner im Projekt per Hotkey">Neuer Ordner im Projekt per Hotkey</a></li><li>15. März 2011 -- <a href="http://www.biggle.de/blog/cookies-in-einer-wpf-applikation" title="Cookies in einer WPF Applikation">Cookies in einer WPF Applikation</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.biggle.de/blog/enumeration-in-einer-combobox-darstellen-wpf-quicky/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cookies in einer WPF Applikation</title>
		<link>http://www.biggle.de/blog/cookies-in-einer-wpf-applikation</link>
		<comments>http://www.biggle.de/blog/cookies-in-einer-wpf-applikation#comments</comments>
		<pubDate>Tue, 15 Mar 2011 14:57:49 +0000</pubDate>
		<dc:creator>Mario Priebe</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.biggle.de/blog/?p=6306</guid>
		<description><![CDATA[Möchte man beispielsweise Authentifikationsinformationen während einer WPF-Client-Sitzung speichern, kann man hier an der Klasse Application die Methoden SetCookie und GetCookie verwenden. Folgendes einfaches Beispiel zeigt wie die Cookieinformationen abgelegt und gelesen werden können: XAML 1 2 3 4 5 6 7 8 9 &#60;StackPanel&#62; &#60;TextBox Name=&#34;tbUserName&#34; /&#62; &#60;TextBox Name=&#34;tbPassword&#34; /&#62; &#60;Button Content=&#34;SetCookie&#34; Click=&#34;Button_Click&#34; /&#62; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Möchte man beispielsweise Authentifikationsinformationen während einer WPF-Client-Sitzung speichern, kann man hier an der Klasse Application die Methoden <a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL21zZG4ubWljcm9zb2Z0LmNvbS9lbi11cy9saWJyYXJ5L3N5c3RlbS53aW5kb3dzLmFwcGxpY2F0aW9uLnNldGNvb2tpZS5hc3B4">SetCookie</a> und <a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL21zZG4ubWljcm9zb2Z0LmNvbS9lbi11cy9saWJyYXJ5L3N5c3RlbS53aW5kb3dzLmFwcGxpY2F0aW9uLmdldGNvb2tpZS5hc3B4">GetCookie</a> verwenden.</p>
<p>Folgendes einfaches Beispiel zeigt wie die Cookieinformationen abgelegt und gelesen werden können:</p>
<p>XAML</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>StackPanel<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>TextBox Name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;tbUserName&quot;</span> <span style="color: #339933;">/&gt;</span>
    <span style="color: #339933;">&lt;</span>TextBox Name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;tbPassword&quot;</span> <span style="color: #339933;">/&gt;</span>        
    <span style="color: #339933;">&lt;</span>Button Content<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;SetCookie&quot;</span> Click<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Button_Click&quot;</span> <span style="color: #339933;">/&gt;</span>   
&nbsp;
    <span style="color: #339933;">&lt;</span>Button Content<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;GetCookie&quot;</span> Click<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Button_Click_1&quot;</span> <span style="color: #339933;">/&gt;</span> 
    <span style="color: #339933;">&lt;</span>TextBlock Name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;tbGetUserName&quot;</span> <span style="color: #339933;">/&gt;</span>        
    <span style="color: #339933;">&lt;</span>TextBlock Name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;tbGetPassword&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>StackPanel<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>C#</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> partial <span style="color: #000000; font-weight: bold;">class</span> MainWindow <span style="color: #339933;">:</span> Window
<span style="color: #009900;">&#123;</span>
    Uri cookiePath <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Uri<span style="color: #009900;">&#40;</span><span style="color: #990000;">System</span><span style="color: #339933;">.</span>Environment<span style="color: #339933;">.</span>GetEnvironmentVariable<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;tmp&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> MainWindow<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        InitializeComponent<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> void Button_Click<span style="color: #009900;">&#40;</span>object sender<span style="color: #339933;">,</span> RoutedEventArgs e<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #990000;">SetCookie</span><span style="color: #009900;">&#40;</span>cookiePath<span style="color: #339933;">,</span> tbUserName<span style="color: #339933;">.</span>Text<span style="color: #339933;">,</span> tbPassword<span style="color: #339933;">.</span>Text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> void Button_Click_1<span style="color: #009900;">&#40;</span>object sender<span style="color: #339933;">,</span> RoutedEventArgs e<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        string c <span style="color: #339933;">=</span> GetCookie<span style="color: #009900;">&#40;</span>cookiePath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>String<span style="color: #339933;">.</span>IsNullOrEmpty<span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">var</span> auth <span style="color: #339933;">=</span> GetAuthentification<span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            tbGetUserName<span style="color: #339933;">.</span>Text <span style="color: #339933;">=</span> auth<span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;Username&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            tbGetPassword<span style="color: #339933;">.</span>Text <span style="color: #339933;">=</span> auth<span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;Password&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> static void <span style="color: #990000;">SetCookie</span><span style="color: #009900;">&#40;</span>Uri uri<span style="color: #339933;">,</span> String name<span style="color: #339933;">,</span> String value<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        String cookie <span style="color: #339933;">=</span> String<span style="color: #339933;">.</span>Format<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Username={0}Password={1}&quot;</span><span style="color: #339933;">,</span> name<span style="color: #339933;">,</span> value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Application<span style="color: #339933;">.</span><span style="color: #990000;">SetCookie</span><span style="color: #009900;">&#40;</span>uri<span style="color: #339933;">,</span> cookie<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> static String GetCookie<span style="color: #009900;">&#40;</span>Uri uri<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        string c <span style="color: #339933;">=</span> String<span style="color: #339933;">.</span><span style="color: #990000;">Empty</span><span style="color: #339933;">;</span>
        try
        <span style="color: #009900;">&#123;</span>
            c <span style="color: #339933;">=</span> Application<span style="color: #339933;">.</span>GetCookie<span style="color: #009900;">&#40;</span>uri<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        catch <span style="color: #009900;">&#40;</span>Exception<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">//set new cookie here</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> c<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> Dictionary<span style="color: #339933;">&lt;</span>string<span style="color: #339933;">,</span> string<span style="color: #339933;">&gt;</span> GetAuthentification<span style="color: #009900;">&#40;</span>string cookie<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">var</span> username <span style="color: #339933;">=</span> cookie<span style="color: #339933;">.</span>Substring<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> cookie<span style="color: #339933;">.</span>IndexOf<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Password=&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>Replace<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Username=&quot;</span><span style="color: #339933;">,</span> string<span style="color: #339933;">.</span><span style="color: #990000;">Empty</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">var</span> password <span style="color: #339933;">=</span> cookie<span style="color: #339933;">.</span>Substring<span style="color: #009900;">&#40;</span>cookie<span style="color: #339933;">.</span>IndexOf<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Password=&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>Replace<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Password=&quot;</span><span style="color: #339933;">,</span> string<span style="color: #339933;">.</span><span style="color: #990000;">Empty</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        Dictionary<span style="color: #339933;">&lt;</span>string<span style="color: #339933;">,</span> string<span style="color: #339933;">&gt;</span> auth <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Dictionary<span style="color: #339933;">&lt;</span>string<span style="color: #339933;">,</span> string<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        auth<span style="color: #339933;">.</span>Add<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Username&quot;</span><span style="color: #339933;">,</span> username<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        auth<span style="color: #339933;">.</span>Add<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Password&quot;</span><span style="color: #339933;">,</span> password<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> auth<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Viel Spaß beim entwickeln : )</p>
<hr /><p style="float:right; font-size:0.9em;">Dieser Beitrag stammt von <a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGU=">Mario Priebe</a>.</p> <img src="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=6306" width="1" height="1" style="display: none;" /><h2  class="related_post_title">Ähnliche Beiträge</h2><ul class="related_post"><li>24. Juli 2011 -- <a href="http://www.biggle.de/blog/databindings-debuggen-wpf" title="DataBindings debuggen &#8211; WPF">DataBindings debuggen &#8211; WPF</a></li><li>23. Juli 2011 -- <a href="http://www.biggle.de/blog/gemeinsamen-validation-style-fr-controls-wpf" title="Gemeinsamen Validation Style f&uuml;r Controls &#8211; WPF">Gemeinsamen Validation Style f&uuml;r Controls &#8211; WPF</a></li><li>25. Juni 2011 -- <a href="http://www.biggle.de/blog/enumeration-in-einer-combobox-darstellen-wpf-quicky" title="Enumeration in einer ComboBox darstellen &#8211; WPF Quicky">Enumeration in einer ComboBox darstellen &#8211; WPF Quicky</a></li><li>6. März 2011 -- <a href="http://www.biggle.de/blog/multibinding-die-zweite" title="MultiBinding die Zweite">MultiBinding die Zweite</a></li><li>14. Februar 2011 -- <a href="http://www.biggle.de/blog/doppelklick-im-datagrid-abfangen-wpf-quicky" title="Doppelklick im DataGrid abfangen &#8211; WPF Quicky">Doppelklick im DataGrid abfangen &#8211; WPF Quicky</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.biggle.de/blog/cookies-in-einer-wpf-applikation/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MultiBinding die Zweite</title>
		<link>http://www.biggle.de/blog/multibinding-die-zweite</link>
		<comments>http://www.biggle.de/blog/multibinding-die-zweite#comments</comments>
		<pubDate>Sun, 06 Mar 2011 15:07:59 +0000</pubDate>
		<dc:creator>Mario Priebe</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://www.biggle.de/blog/?p=6276</guid>
		<description><![CDATA[Ich hatte schon vor einiger Zeit gezeigt (puh, schon wieder 1 1/2 Jahre her..) , wie man im XAML ein MultiBinding implementiert. Nun stand ich vor einem Problem, das ich im XAML ein paar Elemente definiere und im Code weitere Elemente zur Laufzeit hinzufüge. Diese Elemente wollte ich nun vernünftig zusammenbringen. Im Code benötige ich [...]]]></description>
			<content:encoded><![CDATA[<p>Ich hatte schon vor einiger Zeit <a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGUvYmxvZy9zdHJpbmdmb3JtYXQtaW0teGFtbC1xdWlja3k="> gezeigt</a> (<em>puh, schon wieder 1 1/2 Jahre her..</em>) , wie man im XAML ein MultiBinding implementiert. Nun stand ich vor einem Problem, das ich im XAML ein paar Elemente definiere und im Code weitere Elemente zur Laufzeit hinzufüge. Diese Elemente wollte ich nun vernünftig zusammenbringen.</p>
<p>Im Code benötige ich eine Slider-Property und eine Property Namens &#8220;Caption&#8221;, welche einen Text halten soll. Im Xaml habe ich ein TextBlock-Element, welcher den Inhalt der Caption-Property und den aktuellen Wert des Sliders anzeigen soll.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> string Caption <span style="color: #009900;">&#123;</span> get<span style="color: #339933;">;</span> set<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">public</span> Slider Slider <span style="color: #009900;">&#123;</span> get<span style="color: #339933;">;</span> set<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>TextBlock Grid<span style="color: #339933;">.</span>ColumnSpan<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;3&quot;</span> Name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;CaptionTxtBlock&quot;</span> <span style="color: #339933;">/&gt;</span></pre></td></tr></table></div>

<p>Der Slider, welcher von aussen gesetzt wird, bekommt im &#8220;Loading&#8221; noch ein paar Eigenschaften und die Position im UserControl mit:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">Slider<span style="color: #339933;">.</span>Name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;slider&quot;</span><span style="color: #339933;">;</span>
Slider<span style="color: #339933;">.</span>SetValue<span style="color: #009900;">&#40;</span>Grid<span style="color: #339933;">.</span>RowProperty<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Slider<span style="color: #339933;">.</span>SetValue<span style="color: #009900;">&#40;</span>Grid<span style="color: #339933;">.</span>ColumnProperty<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
SliderGrid<span style="color: #339933;">.</span>Children<span style="color: #339933;">.</span>Add<span style="color: #009900;">&#40;</span>Slider<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Anschliessend baue ich mir ein MultiBinding-Objekt, dass nun die beiden benötigen Properties an meiner TextProperty des TextBlockes bindet und entsprechend formatiert ausgibt:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">MultiBinding mb <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MultiBinding<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    Mode <span style="color: #339933;">=</span> BindingMode<span style="color: #339933;">.</span>TwoWay<span style="color: #339933;">,</span>
    UpdateSourceTrigger <span style="color: #339933;">=</span> UpdateSourceTrigger<span style="color: #339933;">.</span>PropertyChanged<span style="color: #339933;">,</span>
    StringFormat <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;{0} ({1:00} %)&quot;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
Binding sliderBinding <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Binding<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    Source <span style="color: #339933;">=</span> Slider<span style="color: #339933;">,</span>
    Path <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PropertyPath<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Value&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
Binding captionBinding <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Binding<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    Source <span style="color: #339933;">=</span> this<span style="color: #339933;">,</span>
    Path <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PropertyPath<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Caption&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
mb<span style="color: #339933;">.</span>Bindings<span style="color: #339933;">.</span>Add<span style="color: #009900;">&#40;</span>captionBinding<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
mb<span style="color: #339933;">.</span>Bindings<span style="color: #339933;">.</span>Add<span style="color: #009900;">&#40;</span>sliderBinding<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
BindingOperations<span style="color: #339933;">.</span>SetBinding<span style="color: #009900;">&#40;</span>CaptionTxtBlock<span style="color: #339933;">,</span> TextBlock<span style="color: #339933;">.</span>TextProperty<span style="color: #339933;">,</span> mb<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Und so sieht das ganze dann aus:</p>
<p><a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGUvYmxvZy93cC1jb250ZW50L3VwbG9hZHMvMjAxMS8wMy8yMDExLTAzLTA2LTE2aDAxXzE4LnBuZw=="><img src="http://www.biggle.de/blog/wp-content/uploads/2011/03/2011-03-06-16h01_18.png" alt="" title="2011-03-06 16h01_18" width="500" class="alignnone size-full wp-image-6285" /></a></p>
<p><a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGUvRXhhbXBsZXMvU2xpZGVyQ29udHJvbC5yYXI=">Download Code</a></p>
<p>Viel Spaß beim entwickeln : )</p>
<hr /><p style="float:right; font-size:0.9em;">Dieser Beitrag stammt von <a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGU=">Mario Priebe</a>.</p> <img src="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=6276" width="1" height="1" style="display: none;" /><h2  class="related_post_title">Ähnliche Beiträge</h2><ul class="related_post"><li>14. Februar 2011 -- <a href="http://www.biggle.de/blog/doppelklick-im-datagrid-abfangen-wpf-quicky" title="Doppelklick im DataGrid abfangen &#8211; WPF Quicky">Doppelklick im DataGrid abfangen &#8211; WPF Quicky</a></li><li>7. August 2010 -- <a href="http://www.biggle.de/blog/wpf-tabbing-gui" title="WPF Tabbing GUI">WPF Tabbing GUI</a></li><li>5. Mai 2010 -- <a href="http://www.biggle.de/blog/combobox-an-objectprovider-binden" title="ComboBox an ObjectDataProvider binden">ComboBox an ObjectDataProvider binden</a></li><li>25. März 2010 -- <a href="http://www.biggle.de/blog/tabcontrol-hoehe-100percent" title="TabControl-Höhe 100%">TabControl-Höhe 100%</a></li><li>5. März 2010 -- <a href="http://www.biggle.de/blog/navigation-paging-in-wpf" title="Navigation / Paging in WPF">Navigation / Paging in WPF</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.biggle.de/blog/multibinding-die-zweite/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

