<?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; XAML</title>
	<atom:link href="http://www.biggle.de/blog/category/markup/xaml-markup/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>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>
		<item>
		<title>Text innerhalb eines TextBlock-Controls formatieren – XAML</title>
		<link>http://www.biggle.de/blog/text-innerhalb-eines-textblock-controls-formatieren-xaml-wpf-silverlight</link>
		<comments>http://www.biggle.de/blog/text-innerhalb-eines-textblock-controls-formatieren-xaml-wpf-silverlight#comments</comments>
		<pubDate>Tue, 30 Nov 2010 18:17:27 +0000</pubDate>
		<dc:creator>Mario Priebe</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://www.biggle.de/blog/?p=6006</guid>
		<description><![CDATA[Um einen Text innerhalb einer Textbox zu formatieren, steht einem die Klasse Run zur Verfügung. Run ist ein Element für fortlaufenden Inhalt auf Inlineebene, das formatierten oder unformatierten Lauftext enthalten kann. 1 2 3 4 &#60;TextBlock FontSize=&#34;28&#34; TextWrapping=&#34;Wrap&#34;&#62; Hier steht &#60;Run Foreground=&#34;Red&#34;&#62;Text&#60;/Run&#62; der &#60;Run FontWeight=&#34;Bold&#34; FontStyle=&#34;Italic&#34; Foreground=&#34;Cyan&#34; FontSize=&#34;38&#34; TextDecorations=&#34;Underline&#34;&#62;verschiedene Formate&#60;/Run&#62; darstellt. &#60;/TextBlock&#62; Einen Zeilenumbruch innerhalb [...]]]></description>
			<content:encoded><![CDATA[<p>Um einen Text innerhalb einer Textbox zu formatieren, steht einem die Klasse <a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL21zZG4ubWljcm9zb2Z0LmNvbS9lbi1VUy9saWJyYXJ5L3N5c3RlbS53aW5kb3dzLmRvY3VtZW50cy5ydW4uYXNweA==">Run</a> zur Verfügung. Run ist ein Element für fortlaufenden Inhalt auf Inlineebene, das formatierten oder unformatierten Lauftext enthalten kann.</p>
<p><a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGUvYmxvZy93cC1jb250ZW50L3VwbG9hZHMvMjAxMC8xMS8yMDEwLTExLTMwLTE5aDA2XzIyLnBuZw=="><img src="http://www.biggle.de/blog/wp-content/uploads/2010/11/2010-11-30-19h06_22.png" alt="" title="2010-11-30 19h06_22" width="500" class="alignnone size-full wp-image-6033" /></a></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;"><span style="color: #339933;">&lt;</span>TextBlock FontSize<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;28&quot;</span> TextWrapping<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Wrap&quot;</span><span style="color: #339933;">&gt;</span>
    Hier steht <span style="color: #339933;">&lt;</span>Run Foreground<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Red&quot;</span><span style="color: #339933;">&gt;</span>Text<span style="color: #339933;">&lt;/</span>Run<span style="color: #339933;">&gt;</span> der
    <span style="color: #339933;">&lt;</span>Run FontWeight<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Bold&quot;</span> FontStyle<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Italic&quot;</span> Foreground<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Cyan&quot;</span> FontSize<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;38&quot;</span> TextDecorations<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Underline&quot;</span><span style="color: #339933;">&gt;</span>verschiedene Formate<span style="color: #339933;">&lt;/</span>Run<span style="color: #339933;">&gt;</span> darstellt<span style="color: #339933;">.</span>
<span style="color: #339933;">&lt;/</span>TextBlock<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Einen Zeilenumbruch innerhalb eines Textblocks erreicht man mit</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>LineBreak <span style="color: #339933;">/&gt;</span></pre></div></div>

<p>Bei einem Hyperlink kann diese Methode auch angewendet werden. (In Silverlight HyperlinkButton)</p>
<p><a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGUvYmxvZy93cC1jb250ZW50L3VwbG9hZHMvMjAxMC8xMS8yMDEwLTExLTMwLTE5aDEyXzQ0LnBuZw=="><img src="http://www.biggle.de/blog/wp-content/uploads/2010/11/2010-11-30-19h12_44.png" alt="" title="2010-11-30 19h12_44" width="500" class="alignnone size-full wp-image-6038" /></a></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>TextBlock TextWrapping<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Wrap&quot;</span><span style="color: #339933;">&gt;</span>            
    <span style="color: #339933;">&lt;</span>Hyperlink TextDecorations<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;None&quot;</span> NavigateUri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.biggle.de&quot;</span><span style="color: #339933;">&gt;</span>
        <span style="color: #339933;">&lt;</span>Italic<span style="color: #339933;">&gt;</span>Hier<span style="color: #339933;">&lt;/</span>Italic<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>Bold<span style="color: #339933;">&gt;</span>steht<span style="color: #339933;">&lt;/</span>Bold<span style="color: #339933;">&gt;</span> ein <span style="color: #339933;">&lt;</span>Underline<span style="color: #339933;">&gt;</span>Hyperlink<span style="color: #339933;">&lt;/</span>Underline<span style="color: #339933;">&gt;</span>                 
        <span style="color: #339933;">&lt;</span>LineBreak <span style="color: #339933;">/&gt;</span>      
            über mehrere <span style="color: #339933;">&lt;</span>Run Foreground<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Red&quot;</span><span style="color: #339933;">&gt;</span>Zeilen<span style="color: #339933;">&lt;/</span>Run<span style="color: #339933;">&gt;.</span>
    <span style="color: #339933;">&lt;/</span>Hyperlink<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>TextBlock<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Im Hyperlinkbeispiel sieht man auch, wie man den Text kursiv,  fett geschrieben und unterstrichen, noch formatieren kann.</p>
<p>Selbst Bilder können so in einem TextBlock mit dargestellt werden:</p>
<p><a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGUvYmxvZy93cC1jb250ZW50L3VwbG9hZHMvMjAxMC8xMS8yMDEwLTExLTMwLTE5aDE0XzIzLnBuZw=="><img src="http://www.biggle.de/blog/wp-content/uploads/2010/11/2010-11-30-19h14_23.png" alt="" title="2010-11-30 19h14_23" width="500" class="alignnone size-full wp-image-6040" /></a></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>TextBlock<span style="color: #339933;">&gt;</span>
    Das bin ich
    <span style="color: #339933;">&lt;</span>LineBreak <span style="color: #339933;">/&gt;</span>
    <span style="color: #339933;">&lt;</span>Image Source<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;/Images/IMG_6911_small.jpg&quot;</span> Width<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;50&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>TextBlock<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Es ist auch möglich, innerhalb des Textblock-Controls Werte aus einem Binding heraus darzustellen:</p>
<p><a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGUvYmxvZy93cC1jb250ZW50L3VwbG9hZHMvMjAxMC8xMS8yMDEwLTExLTMwLTE5aDA5XzM5LnBuZw=="><img src="http://www.biggle.de/blog/wp-content/uploads/2010/11/2010-11-30-19h09_39.png" alt="" title="2010-11-30 19h09_39" width="500" class="alignnone size-full wp-image-6035" /></a></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>TextBlock DataContext<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{Binding Order}&quot;</span> TextWrapping<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Wrap&quot;</span><span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>Run TextDecorations<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Underline&quot;</span><span style="color: #339933;">&gt;</span>Ihre Bestellung<span style="color: #339933;">&lt;/</span>Run<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>LineBreak <span style="color: #339933;">/&gt;</span>
    <span style="color: #339933;">&lt;</span>Run<span style="color: #339933;">&gt;</span>Produkt<span style="color: #339933;">:&lt;/</span>Run<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>TextBlock Text<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{Binding productName}&quot;</span> <span style="color: #339933;">/&gt;</span>
    <span style="color: #339933;">&lt;</span>Run<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&lt;/</span>Run<span style="color: #339933;">&gt;</span>
        <span style="color: #339933;">&lt;</span>TextBlock Text<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{Binding quantity}&quot;</span> <span style="color: #339933;">/&gt;</span>
    <span style="color: #339933;">&lt;</span>Run<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&lt;/</span>Run<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>TextBlock<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>


<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
</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>
    <span style="color: #000000; font-weight: bold;">public</span> Order Order <span style="color: #009900;">&#123;</span> get<span style="color: #339933;">;</span> set<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</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>
        LoadOrders<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>  
    <span style="color: #000000; font-weight: bold;">private</span> void LoadOrders<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        Order <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Order<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Order<span style="color: #339933;">.</span>productName <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Mountainbike&quot;</span><span style="color: #339933;">;</span>
        Order<span style="color: #339933;">.</span>quantity <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
        this<span style="color: #339933;">.</span>DataContext <span style="color: #339933;">=</span> this<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><br class="spacer_" /></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=6006" width="1" height="1" style="display: none;" /><h2  class="related_post_title">Ähnliche Beiträge</h2><ul class="related_post"><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/tooltip-an-einem-disabled-button-xaml" title="ToolTip an einem &#8220;disabled Button&#8221; &#8211; XAML Quicky">ToolTip an einem &#8220;disabled Button&#8221; &#8211; XAML Quicky</a></li><li>14. Februar 2011 -- <a href="http://www.biggle.de/blog/texttrimming-xaml-quicky" title="TextTrimming &#8211;  XAML Quicky">TextTrimming &#8211;  XAML Quicky</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><li>7. August 2010 -- <a href="http://www.biggle.de/blog/wpf-tabbing-gui" title="WPF Tabbing GUI">WPF Tabbing GUI</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.biggle.de/blog/text-innerhalb-eines-textblock-controls-formatieren-xaml-wpf-silverlight/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eigenes Hyperlink Control &#8211; XAML</title>
		<link>http://www.biggle.de/blog/eigenes-hyperlink-control-xaml</link>
		<comments>http://www.biggle.de/blog/eigenes-hyperlink-control-xaml#comments</comments>
		<pubDate>Tue, 30 Nov 2010 08:14:21 +0000</pubDate>
		<dc:creator>Mario Priebe</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://www.biggle.de/blog/?p=6024</guid>
		<description><![CDATA[Der eine oder andere hat dies sicher schon bemerkt. Wenn man im XAML ein Hyperlink Element einsetzt und NavigateUri mit der entsprechenden Adresse definiert, könnte man annehmen, dass das ausreicht um den Link aufzurufen. Doch leider ist dem nicht so. Man könnte aber sein eigenes Control schreiben, welches diese Funktionalität beinhaltet. Dazu fügt man ein [...]]]></description>
			<content:encoded><![CDATA[<p>Der eine oder andere hat dies sicher schon bemerkt. Wenn man im XAML ein Hyperlink Element einsetzt und NavigateUri mit der entsprechenden Adresse definiert, könnte man annehmen, dass das ausreicht um den Link aufzurufen. Doch leider ist dem nicht so.</p>
<p>Man könnte aber sein eigenes Control schreiben, welches diese Funktionalität beinhaltet.</p>
<p>Dazu fügt man ein neues UserControl hinzu und benennt dieses &#8220;<strong>Link</strong>&#8220;. Dieses UserControl muss nun so abgeändert werden, dass dieses von Hyperlink ableitet. Im Xaml muss der Knoten UserControl in Hyperlink umbenannt und im code-behind muss das UserControl auch dahingehend abgeändert werden.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>Hyperlink x<span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">Class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;WPFSpielwiese.Link&quot;</span>
             xmlns<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span>
             xmlns<span style="color: #339933;">:</span>x<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;/</span>Hyperlink<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Nun registrieren wir uns am Event &#8220;<strong>RequestNavigate</strong>&#8221; und implementieren einen einfachen <strong>Process.Start</strong> um die URL aus NavigateUri aufzurufen. Die Fehlerbehandlung lass ich an dieser Stelle mal weg.</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
</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> <span style="color: #990000;">Link</span> <span style="color: #339933;">:</span> Hyperlink
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #990000;">Link</span><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>
        this<span style="color: #339933;">.</span>RequestNavigate <span style="color: #339933;">+=</span> <span style="color: #000000; font-weight: bold;">new</span> RequestNavigateEventHandler<span style="color: #009900;">&#40;</span>Link_RequestNavigate<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    void Link_RequestNavigate<span style="color: #009900;">&#40;</span>object sender<span style="color: #339933;">,</span> RequestNavigateEventArgs e<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        Process<span style="color: #339933;">.</span>Start<span style="color: #009900;">&#40;</span>this<span style="color: #339933;">.</span>NavigateUri<span style="color: #339933;">.</span>ToString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Eingesetzt wird das ganze dann wie folgt:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">xmlns<span style="color: #339933;">:</span>mp<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;clr-namespace:WPFSpielwiese&quot;</span>
<span style="color: #339933;">..</span>
<span style="color: #339933;">&lt;</span>TextBlock<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>mp<span style="color: #339933;">:</span><span style="color: #990000;">Link</span> NavigateUri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.biggle.de&quot;</span><span style="color: #339933;">&gt;</span>Biggle<span style="color: #0000ff;">'s Blog&lt;/mp:Link&gt;
&lt;/TextBlock&gt;</span></pre></td></tr></table></div>

<p><br class="spacer_" /></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=6024" width="1" height="1" style="display: none;" /><h2  class="related_post_title">Ähnliche Beiträge</h2><ul class="related_post"><li>Keine ähnliche Beiträge vorhanden</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.biggle.de/blog/eigenes-hyperlink-control-xaml/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Verwenden von SoundPlayerAction und SoundPlayer- WPF Quicky</title>
		<link>http://www.biggle.de/blog/verwenden-von-soundplayeraction-wpf-quicky</link>
		<comments>http://www.biggle.de/blog/verwenden-von-soundplayeraction-wpf-quicky#comments</comments>
		<pubDate>Sun, 10 Oct 2010 17:59:31 +0000</pubDate>
		<dc:creator>Mario Priebe</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[XAML]]></category>
		<category><![CDATA[Quicky]]></category>

		<guid isPermaLink="false">http://www.biggle.de/blog/?p=5476</guid>
		<description><![CDATA[Sounds mit WPF abspielen kann man über der Klasse SoundPlayerAction. Implementiert werden kann das ganze sowohl im Xaml als auch im Code. Im Xaml: 1 2 3 4 5 6 7 &#60;Button Content=&#34;Play Sound&#34;&#62; &#60;Button.Triggers&#62; &#60;EventTrigger RoutedEvent=&#34;Button.Click&#34;&#62; &#60;SoundPlayerAction Source=&#34;pack://siteoforigin:,,,/Media/Windows Exclamation.wav&#34; /&#62; &#60;/EventTrigger&#62; &#60;/Button.Triggers&#62; &#60;/Button&#62; Im Xaml muss der Pfad zur Datei mit absoluter Angabe oder [...]]]></description>
			<content:encoded><![CDATA[<p>Sounds mit WPF abspielen kann man über der Klasse <a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL21zZG4ubWljcm9zb2Z0LmNvbS9lbi11cy9saWJyYXJ5L21zNjEyOTU3LmFzcHg="><strong>SoundPlayerAction</strong></a>. Implementiert werden kann das ganze sowohl im Xaml als auch im Code.</p>
<p>Im Xaml:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>Button Content<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Play Sound&quot;</span><span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>Button<span style="color: #339933;">.</span>Triggers<span style="color: #339933;">&gt;</span>
        <span style="color: #339933;">&lt;</span>EventTrigger RoutedEvent<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Button.Click&quot;</span><span style="color: #339933;">&gt;</span>
            <span style="color: #339933;">&lt;</span>SoundPlayerAction Source<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;pack://siteoforigin:,,,/Media/Windows Exclamation.wav&quot;</span> <span style="color: #339933;">/&gt;</span>
        <span style="color: #339933;">&lt;/</span>EventTrigger<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;/</span>Button<span style="color: #339933;">.</span>Triggers<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>Button<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p><div class="note"><div class="notetip">Im Xaml muss der Pfad zur Datei mit absoluter Angabe oder als siteoforgin-Datei (Inhalt, immer kopieren) angeben werden.</div></div><br />
<a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGUvYmxvZy93cC1jb250ZW50L3VwbG9hZHMvMjAxMC8xMC9Tb3VuZFBsYXlBY3Rpb24ucG5n"><img src="http://www.biggle.de/blog/wp-content/uploads/2010/10/SoundPlayAction.png" alt="" title="SoundPlayAction" width="416" height="259" class="alignnone size-full wp-image-5477" /></a></p>
<p>Im Code ist die Instanzierung der Klasse <strong>SoundPlayer </strong>und der Methodenaufruf Play ausreichend:</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;">SoundPlayer sp <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SoundPlayer<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Media/Windows Exclamation.wav&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
sp<span style="color: #339933;">.</span>Play<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Auch hier muss das entsprechende Mediafile über den Eigenschaften immer in das Ausgabeverzeichnis kopiert werden.</p>
<p>Die Mediadatei kann über ein Dateipfad, einer Url und von einem Stream aus geladen werden.</p>
<p>Ergänzend sollte ich noch erwähnen, das die Klasse SoundPlayer, welche im Code implementiert wird, mehrere Methoden zum Abspielen von Sounddateien hat. Zum einen die genannte Play, welche das File asynchron abspielt. Die Methode PlaySync hingegen spielt das ganze synchron ab und mit PlayLooping wird das Mediafile in einer Endlosschleife abgespielt. Über der Methode Stop wird das Abspielen abgebrochen.</p>
<p>Standardmässig wird das File erst beim ersten Abspielen geladen, über die Methoden Load und LoadAsync kann dieser Vorgang im Voraus gemacht werden. Das Event LoadCompleted wird gefeuert, wenn das File geladen wurde.</p>
<p><div class="note"><div class="noteclassic">Abgespielt werden können mit den Klassen SoundPlayerAction und SoundPlayer lediglich *.wav Dateien.</div></div></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=5476" 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>25. November 2009 -- <a href="http://www.biggle.de/blog/mulitline-textbox-xaml-quicky" title="Multiline TextBox &#8211; XAML Quicky">Multiline TextBox &#8211; XAML Quicky</a></li><li>18. Juni 2009 -- <a href="http://www.biggle.de/blog/emailvalidationconverter-wpf-quicky" title="EMailValidationConverter &#8211; WPF Quicky">EMailValidationConverter &#8211; WPF Quicky</a></li><li>18. Juni 2009 -- <a href="http://www.biggle.de/blog/birthdayconverter-wpf-quicky" title="BirthdayConverter &#8211; WPF Quicky">BirthdayConverter &#8211; WPF Quicky</a></li><li>26. Februar 2009 -- <a href="http://www.biggle.de/blog/contextmenu-wpf-xaml-quicky" title="contextmenu &#8211; WPF / XAML Quicky">contextmenu &#8211; WPF / XAML Quicky</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.biggle.de/blog/verwenden-von-soundplayeraction-wpf-quicky/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Escape-Sequenz in XAML</title>
		<link>http://www.biggle.de/blog/escape-sequenz-in-xaml</link>
		<comments>http://www.biggle.de/blog/escape-sequenz-in-xaml#comments</comments>
		<pubDate>Sun, 15 Aug 2010 13:33:13 +0000</pubDate>
		<dc:creator>Mario Priebe</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[MarkUp]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://www.biggle.de/blog/?p=5136</guid>
		<description><![CDATA[Möchte man im XAML in einem Attribut z.B. Text oder Content geschweifte Klammern verwenden, muss man diese entsprechend escapen. Hier verwendet man vor dem eigentlichen Inhalt zwei geschweifte Klammern {} &#60;TextBlock Text=&#34;{}{Welt}&#34; /&#62; Wird der Text mit weiteren Text außerhalb der geschweiften Klammern kombiniert, macht XAML das automatisch &#60;TextBlock Text=&#34;Hallo {Welt}&#34; /&#62; Dieser Beitrag stammt [...]]]></description>
			<content:encoded><![CDATA[<p>Möchte man im XAML in einem Attribut z.B. Text oder Content geschweifte Klammern verwenden,</p>
<p><a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGUvYmxvZy93cC1jb250ZW50L3VwbG9hZHMvMjAxMC8wOC9NYXJrdXBFeHRlbnNpb25Fc2NhcGUucG5n"><img class="alignnone size-full wp-image-5137" title="MarkupExtensionEscape" src="http://www.biggle.de/blog/wp-content/uploads/2010/08/MarkupExtensionEscape.png" alt="" width="369" height="127" /></a></p>
<p>muss man diese entsprechend escapen. Hier verwendet man vor dem eigentlichen Inhalt zwei geschweifte Klammern {}</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>TextBlock Text<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{}{Welt}&quot;</span> <span style="color: #339933;">/&gt;</span></pre></div></div>

<p>Wird der Text mit weiteren Text außerhalb der geschweiften Klammern kombiniert, macht XAML das automatisch</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>TextBlock Text<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Hallo {Welt}&quot;</span> <span style="color: #339933;">/&gt;</span></pre></div></div>

<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=5136" width="1" height="1" style="display: none;" /><h2  class="related_post_title">Ähnliche Beiträge</h2><ul class="related_post"><li>Keine ähnliche Beiträge vorhanden</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.biggle.de/blog/escape-sequenz-in-xaml/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

