<?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; CodeSnippet</title>
	<atom:link href="http://www.biggle.de/blog/tag/codesnippet/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>WebSequenceDiagrams API mit .NET</title>
		<link>http://www.biggle.de/blog/websequencediagrams-api-mit-net</link>
		<comments>http://www.biggle.de/blog/websequencediagrams-api-mit-net#comments</comments>
		<pubDate>Wed, 28 Dec 2011 20:06:47 +0000</pubDate>
		<dc:creator>Mario Priebe</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[CodeSnippet]]></category>
		<category><![CDATA[Onlinetools]]></category>

		<guid isPermaLink="false">http://www.biggle.de/blog/websequencediagrams-api-mit-net</guid>
		<description><![CDATA[Heute bin ich durch einen Tweet auf websequencediagrams aufmerksam geworden. Mit websequencediagrams kann man sich über eine einfache Textnotation ein SequenzDiagramm in verschiedenen Styles erstellen lassen. Die Applikation bietet aber auch eine Schnittstelle die es einem ermöglicht mit .NET ein solches Diagramm zu erstellen. Folgendes CodeSnippet soll zeigen wie: 1 public void SaveSequenceDiagram(string data, string [...]]]></description>
			<content:encoded><![CDATA[<p>Heute bin ich durch einen <a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cHM6Ly90d2l0dGVyLmNvbS8jIS9BbGV4WmVpdGxlci9zdGF0dXNlcy8xNTE5NDk0Mzg2MjQwODgwNjQ=" target=\"_blank\">Tweet</a> auf <a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy53ZWJzZXF1ZW5jZWRpYWdyYW1zLmNvbS8=">websequencediagrams</a> aufmerksam geworden. Mit websequencediagrams kann man sich über eine einfache Textnotation ein SequenzDiagramm in verschiedenen Styles erstellen lassen. </p>
<p>Die Applikation bietet aber auch eine Schnittstelle die es einem ermöglicht mit .NET ein solches Diagramm zu erstellen.</p>
<p>Folgendes CodeSnippet soll zeigen wie:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:788cb751-668a-410d-bb7f-c9d398cd237e" class="wlWriterEditableSmartContent">
<pre style=" width: 500px; height: 350px;background-color:White;overflow: auto;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #008080;"> 1</span> <span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> SaveSequenceDiagram(</span><span style="color: #0000FF;">string</span><span style="color: #000000;"> data, </span><span style="color: #0000FF;">string</span><span style="color: #000000;"> outFile, SequenceStyle style, SequenceOutputFormat outputFormat)
</span><span style="color: #008080;"> 2</span> <span style="color: #000000;">{
</span><span style="color: #008080;"> 3</span> <span style="color: #000000;">    var request </span><span style="color: #000000;">=</span><span style="color: #000000;"> WebRequest.Create(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">http://www.websequencediagrams.com</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;"> 4</span> <span style="color: #000000;">    request.Method </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">&quot;</span><span style="color: #800000;">POST</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">;
</span><span style="color: #008080;"> 5</span> <span style="color: #000000;">
</span><span style="color: #008080;"> 6</span> <span style="color: #000000;">    </span><span style="color: #0000FF;">string</span><span style="color: #000000;"> postData </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">string</span><span style="color: #000000;">.Format(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">style={0}&amp;format={1}&amp;message={2}</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, style, outputFormat, HttpUtility.UrlEncode(data, Encoding.UTF8));
</span><span style="color: #008080;"> 7</span> <span style="color: #000000;">
</span><span style="color: #008080;"> 8</span> <span style="color: #000000;">    </span><span style="color: #0000FF;">byte</span><span style="color: #000000;">[] byteArray </span><span style="color: #000000;">=</span><span style="color: #000000;"> Encoding.UTF8.GetBytes(postData);
</span><span style="color: #008080;"> 9</span> <span style="color: #000000;">    request.ContentType </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">&quot;</span><span style="color: #800000;">application/x-www-form-urlencoded</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">;
</span><span style="color: #008080;">10</span> <span style="color: #000000;">    request.ContentLength </span><span style="color: #000000;">=</span><span style="color: #000000;"> byteArray.Length;
</span><span style="color: #008080;">11</span> <span style="color: #000000;">
</span><span style="color: #008080;">12</span> <span style="color: #000000;">    </span><span style="color: #008000;">//</span><span style="color: #008000;">because error: The remote server returned an error: (417) Expectation Failed.</span><span style="color: #008000;">
</span><span style="color: #008080;">13</span> <span style="color: #008000;"></span><span style="color: #000000;">    System.Net.ServicePointManager.Expect100Continue </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">false</span><span style="color: #000000;">;
</span><span style="color: #008080;">14</span> <span style="color: #000000;">
</span><span style="color: #008080;">15</span> <span style="color: #000000;">    Stream dataStream </span><span style="color: #000000;">=</span><span style="color: #000000;"> request.GetRequestStream();
</span><span style="color: #008080;">16</span> <span style="color: #000000;">    dataStream.Write(byteArray, </span><span style="color: #800080;">0</span><span style="color: #000000;">, byteArray.Length);
</span><span style="color: #008080;">17</span> <span style="color: #000000;">    dataStream.Close();
</span><span style="color: #008080;">18</span> <span style="color: #000000;">
</span><span style="color: #008080;">19</span> <span style="color: #000000;">    dataStream </span><span style="color: #000000;">=</span><span style="color: #000000;"> request.GetResponse().GetResponseStream();
</span><span style="color: #008080;">20</span> <span style="color: #000000;">    </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (dataStream </span><span style="color: #000000;">==</span><span style="color: #000000;"> </span><span style="color: #0000FF;">null</span><span style="color: #000000;">) </span><span style="color: #0000FF;">return</span><span style="color: #000000;">;
</span><span style="color: #008080;">21</span> <span style="color: #000000;">
</span><span style="color: #008080;">22</span> <span style="color: #000000;">    </span><span style="color: #0000FF;">using</span><span style="color: #000000;"> (var reader </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> StreamReader(dataStream))
</span><span style="color: #008080;">23</span> <span style="color: #000000;">    {
</span><span style="color: #008080;">24</span> <span style="color: #000000;">        </span><span style="color: #0000FF;">string</span><span style="color: #000000;"> responseFromServer </span><span style="color: #000000;">=</span><span style="color: #000000;"> reader.ReadToEnd();
</span><span style="color: #008080;">25</span> <span style="color: #000000;">        var image </span><span style="color: #000000;">=</span><span style="color: #000000;"> responseFromServer.Substring(</span><span style="color: #800080;">12</span><span style="color: #000000;">, </span><span style="color: #800080;">9</span><span style="color: #000000;">);
</span><span style="color: #008080;">26</span> <span style="color: #000000;">
</span><span style="color: #008080;">27</span> <span style="color: #000000;">        </span><span style="color: #0000FF;">using</span><span style="color: #000000;"> (var webClient </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> WebClient())
</span><span style="color: #008080;">28</span> <span style="color: #000000;">        {
</span><span style="color: #008080;">29</span> <span style="color: #000000;">            </span><span style="color: #0000FF;">byte</span><span style="color: #000000;">[] resp </span><span style="color: #000000;">=</span><span style="color: #000000;"> webClient.DownloadData(</span><span style="color: #0000FF;">string</span><span style="color: #000000;">.Format(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">http://www.websequencediagrams.com?{0}={1}</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, outputFormat, image));
</span><span style="color: #008080;">30</span> <span style="color: #000000;">            </span><span style="color: #0000FF;">using</span><span style="color: #000000;"> (var fileStream </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> FileStream(outFile, FileMode.OpenOrCreate))
</span><span style="color: #008080;">31</span> <span style="color: #000000;">            {
</span><span style="color: #008080;">32</span> <span style="color: #000000;">                fileStream.Write(resp, </span><span style="color: #800080;">0</span><span style="color: #000000;">, resp.Length);
</span><span style="color: #008080;">33</span> <span style="color: #000000;">            }
</span><span style="color: #008080;">34</span> <span style="color: #000000;">        }
</span><span style="color: #008080;">35</span> <span style="color: #000000;">    }
</span><span style="color: #008080;">36</span> <span style="color: #000000;">
</span><span style="color: #008080;">37</span> <span style="color: #000000;">    dataStream.Close();
</span><span style="color: #008080;">38</span> <span style="color: #000000;">}</span></div>
</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:9D7513F9-C04C-4721-824A-2B34F0212519:bc5f6fd3-7db4-4684-b0f4-22a632eb6eb0" class="wlWriterEditableSmartContent">
<pre style=" width: 500px; height: 100px;background-color:White;overflow: auto;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #008080;">1</span> <span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">enum</span><span style="color: #000000;"> SequenceOutputFormat
</span><span style="color: #008080;">2</span> <span style="color: #000000;">{
</span><span style="color: #008080;">3</span> <span style="color: #000000;">    img,
</span><span style="color: #008080;">4</span> <span style="color: #000000;">    pdf,
</span><span style="color: #008080;">5</span> <span style="color: #000000;">    png,
</span><span style="color: #008080;">6</span> <span style="color: #000000;">    svg
</span><span style="color: #008080;">7</span> <span style="color: #000000;">}</span></div>
</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:9D7513F9-C04C-4721-824A-2B34F0212519:ed8115c8-2788-4c57-980a-492900ffb51b" class="wlWriterEditableSmartContent">
<pre style=" width: 500px; height: 100px;background-color:White;overflow: auto;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #008080;"> 1</span> <span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">enum</span><span style="color: #000000;"> SequenceStyle
</span><span style="color: #008080;"> 2</span> <span style="color: #000000;">{
</span><span style="color: #008080;"> 3</span> <span style="color: #000000;">    @default,
</span><span style="color: #008080;"> 4</span> <span style="color: #000000;">    earth,
</span><span style="color: #008080;"> 5</span> <span style="color: #000000;">    modernblue,
</span><span style="color: #008080;"> 6</span> <span style="color: #000000;">    mscgen,
</span><span style="color: #008080;"> 7</span> <span style="color: #000000;">    omegapple,
</span><span style="color: #008080;"> 8</span> <span style="color: #000000;">    qsd,
</span><span style="color: #008080;"> 9</span> <span style="color: #000000;">    rose,
</span><span style="color: #008080;">10</span> <span style="color: #000000;">    roundgreen,
</span><span style="color: #008080;">11</span> <span style="color: #000000;">    napkin,
</span><span style="color: #008080;">12</span> <span style="color: #000000;">}</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Aufgerufen wird das ganze wie folgt:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:6f5f80bd-3c3e-4000-ab5e-0adf3c8042d1" class="wlWriterEditableSmartContent">
<pre style=" width: 500px; height: 80px;background-color:White;overflow: auto;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #008080;">1</span> <span style="color: #000000;">SaveSequenceDiagram(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Alice-&gt;Bob: Authentication Request\nactivate Bob\nBob-&gt;Alice: Authentication Response\ndeactivate Bob</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, </span><span style="color: #800000;">&quot;</span><span style="color: #800000;">out.svg</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">,
</span><span style="color: #008080;">2</span> <span style="color: #000000;">                SequenceStyle.roundgreen, SequenceOutputFormat.svg);</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Beim Aufruf an den Dienst hab ich zu Anfang immer folgende Fehlermeldung bekommen “<em>The remote server returned an error: (417) Expectation Failed.</em>” Die Problemlösung habe ich nach etwas googlen, beim <a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2dvcmRvbi1icmV1ZXIuZGUvcG9zdC8yMDA5LzAxLzA2L1R3aXR0ZXItRmVobGVyLTQxNy0oRXhwZWN0YXRpb24tRmFpbGVkKS5hc3B4">Gordon</a> finden können. Danke nochmal an dieser Stelle.</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=6794" width="1" height="1" style="display: none;" /><h2  class="related_post_title">Ähnliche Beiträge</h2><ul class="related_post"><li>5. Mai 2011 -- <a href="http://www.biggle.de/blog/prufen-ob-ein-string-eine-guid-ist" title="Prüfen ob ein String eine Guid ist">Prüfen ob ein String eine Guid ist</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>14. Februar 2011 -- <a href="http://www.biggle.de/blog/bedingte-formatierung-im-datagrid-wpf" title="Bedingte Formatierung im Datagrid &#8211; WPF Quicky">Bedingte Formatierung im Datagrid &#8211; WPF Quicky</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.biggle.de/blog/websequencediagrams-api-mit-net/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prüfen ob ein String eine Guid ist</title>
		<link>http://www.biggle.de/blog/prufen-ob-ein-string-eine-guid-ist</link>
		<comments>http://www.biggle.de/blog/prufen-ob-ein-string-eine-guid-ist#comments</comments>
		<pubDate>Thu, 05 May 2011 13:59:07 +0000</pubDate>
		<dc:creator>Mario Priebe</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[CSharp]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[CodeSnippet]]></category>
		<category><![CDATA[ExtensionMethod]]></category>

		<guid isPermaLink="false">http://www.biggle.de/blog/?p=6379</guid>
		<description><![CDATA[Es gibt jede Menge Ansätze, um zu prüfen ob ein String eine Guid ist. Zum einen ist es möglich, den String mit RegEx zu prüfen: 1 2 3 4 5 6 using System.Text.RegularExpressions; ... private bool IsStringValidGuid&#40;string s&#41; &#123; return string.IsNullOrEmpty&#40;s&#41; ? false : new Regex&#40;@&#34;^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$&#34;&#41;.IsMatch&#40;s&#41;; &#125; Als ExtensionMethod könnte das wie folgt aussehen: 1 [...]]]></description>
			<content:encoded><![CDATA[<p>Es gibt jede Menge Ansätze, um zu prüfen ob ein String eine <a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL21zZG4ubWljcm9zb2Z0LmNvbS9lbi11cy9saWJyYXJ5L3N5c3RlbS5ndWlkLmFzcHg=">Guid </a> ist. Zum einen ist es möglich, den String mit <a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL21zZG4ubWljcm9zb2Z0LmNvbS9lbi1VUy9saWJyYXJ5L3N5c3RlbS50ZXh0LnJlZ3VsYXJleHByZXNzaW9ucy5yZWdleC5hc3B4">RegEx</a>  zu prüfen:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">using <span style="color: #990000;">System</span><span style="color: #339933;">.</span>Text<span style="color: #339933;">.</span>RegularExpressions<span style="color: #339933;">;</span>
<span style="color: #339933;">...</span>
<span style="color: #000000; font-weight: bold;">private</span> bool IsStringValidGuid<span style="color: #009900;">&#40;</span>string s<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> string<span style="color: #339933;">.</span>IsNullOrEmpty<span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span> ? <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">new</span> Regex<span style="color: #009900;">&#40;</span><span style="color: #339933;">@</span><span style="color: #0000ff;">&quot;^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>IsMatch<span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Als ExtensionMethod könnte das wie folgt aussehen:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">using <span style="color: #990000;">System</span><span style="color: #339933;">.</span>Text<span style="color: #339933;">.</span>RegularExpressions<span style="color: #339933;">;</span>
<span style="color: #339933;">...</span>
<span style="color: #000000; font-weight: bold;">public</span> static bool IsStringValidGuid<span style="color: #009900;">&#40;</span>this string s<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> string<span style="color: #339933;">.</span>IsNullOrEmpty<span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span> ? <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">new</span> Regex<span style="color: #009900;">&#40;</span><span style="color: #339933;">@</span><span style="color: #0000ff;">&quot;^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>IsMatch<span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Zum anderen kann man sich jeden Character in dem String anschauen und prüfen ob dieser im <a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2RlLndpa2lwZWRpYS5vcmcvd2lraS9IZXhhZGV6aW1hbHN5c3RlbQ==">Hexadezimalsystem</a> vorkommt.</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/// &lt;summary&gt;</span>
<span style="color: #666666; font-style: italic;">/// Prueft ob der uebergebene String eine Guid ist.</span>
<span style="color: #666666; font-style: italic;">/// &lt;/summary&gt;</span>
<span style="color: #666666; font-style: italic;">/// &lt;param name=&quot;s&quot;&gt;string&lt;/param&gt;</span>
<span style="color: #666666; font-style: italic;">/// &lt;returns&gt;bool&lt;/returns&gt;</span>
<span style="color: #000000; font-weight: bold;">public</span> bool IsStringValidGuid<span style="color: #009900;">&#40;</span>string s<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    int hexchars <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span>char c in s<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>IsValidHexChar<span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            hexchars<span style="color: #339933;">++;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> hexchars <span style="color: #339933;">==</span> <span style="color: #cc66cc;">32</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">private</span> bool IsValidHexChar<span style="color: #009900;">&#40;</span>char hexChar<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span>hexChar <span style="color: #339933;">&gt;=</span> <span style="color: #208080;">0x30</span> <span style="color: #339933;">&amp;&amp;</span> hexChar <span style="color: #339933;">&lt;=</span> <span style="color: #208080;">0x39</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">//IsValidHexDigit</span>
        <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span>hexChar <span style="color: #339933;">&gt;=</span> <span style="color: #208080;">0x61</span> <span style="color: #339933;">&amp;&amp;</span> hexChar <span style="color: #339933;">&lt;=</span> <span style="color: #208080;">0x66</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">//IsValidLowerHexLetter</span>
        <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span>hexChar <span style="color: #339933;">&gt;=</span> <span style="color: #208080;">0x41</span> <span style="color: #339933;">&amp;&amp;</span> hexChar <span style="color: #339933;">&lt;=</span> <span style="color: #208080;">0x46</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//IsValidUpperHexLetter</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Als ExtensionMethod:</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/// &lt;summary&gt;</span>
<span style="color: #666666; font-style: italic;">/// Prueft ob der uebergebene String eine Guid ist.</span>
<span style="color: #666666; font-style: italic;">/// &lt;/summary&gt;</span>
<span style="color: #666666; font-style: italic;">/// &lt;param name=&quot;s&quot;&gt;string&lt;/param&gt;</span>
<span style="color: #666666; font-style: italic;">/// &lt;returns&gt;bool&lt;/returns&gt;</span>
<span style="color: #000000; font-weight: bold;">public</span> static bool IsStringValidGuid<span style="color: #009900;">&#40;</span>this string s<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    int hexchars <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span>char c in s<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>IsValidHexChar<span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            hexchars<span style="color: #339933;">++;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> hexchars <span style="color: #339933;">==</span> <span style="color: #cc66cc;">32</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">private</span> bool IsValidHexChar<span style="color: #009900;">&#40;</span>char hexChar<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span>hexChar <span style="color: #339933;">&gt;=</span> <span style="color: #208080;">0x30</span> <span style="color: #339933;">&amp;&amp;</span> hexChar <span style="color: #339933;">&lt;=</span> <span style="color: #208080;">0x39</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">//IsValidHexDigit</span>
        <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span>hexChar <span style="color: #339933;">&gt;=</span> <span style="color: #208080;">0x61</span> <span style="color: #339933;">&amp;&amp;</span> hexChar <span style="color: #339933;">&lt;=</span> <span style="color: #208080;">0x66</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">//IsValidLowerHexLetter</span>
        <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span>hexChar <span style="color: #339933;">&gt;=</span> <span style="color: #208080;">0x41</span> <span style="color: #339933;">&amp;&amp;</span> hexChar <span style="color: #339933;">&lt;=</span> <span style="color: #208080;">0x46</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//IsValidUpperHexLetter</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Die RegEx-Version finde ich eleganter (da Einzeiler), jedoch die Zeichen einzeln zu prüfen, finde ich für das Verständnis besser.</p>
<p>Wie auch immer, funktionieren werden sicher noch mehr Wege&#8230;<br />
In diesem Sinne, 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=6379" width="1" height="1" style="display: none;" /><h2  class="related_post_title">Ähnliche Beiträge</h2><ul class="related_post"><li>28. Dezember 2011 -- <a href="http://www.biggle.de/blog/websequencediagrams-api-mit-net" title="WebSequenceDiagrams API mit .NET">WebSequenceDiagrams API mit .NET</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>14. Februar 2011 -- <a href="http://www.biggle.de/blog/bedingte-formatierung-im-datagrid-wpf" title="Bedingte Formatierung im Datagrid &#8211; WPF Quicky">Bedingte Formatierung im Datagrid &#8211; WPF Quicky</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.biggle.de/blog/prufen-ob-ein-string-eine-guid-ist/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ToolTip an einem &#8220;disabled Button&#8221; &#8211; XAML Quicky</title>
		<link>http://www.biggle.de/blog/tooltip-an-einem-disabled-button-xaml</link>
		<comments>http://www.biggle.de/blog/tooltip-an-einem-disabled-button-xaml#comments</comments>
		<pubDate>Mon, 14 Feb 2011 19:05:57 +0000</pubDate>
		<dc:creator>Mario Priebe</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[CodeSnippet]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://www.biggle.de/blog/?p=6257</guid>
		<description><![CDATA[Stellt man einen Button auf &#8220;disabled&#8221;, wird leider kein Tooltip mehr angezeigt. Möchte man dem entgegenwirken, verwendet man die Methode ShowOnDisabled am ToolTipService: 1 &#60;Button Content=&#34;Hier klicken&#34; ToolTipService.ShowOnDisabled=&#34;True&#34; IsEnabled=&#34;False&#34; ToolTip=&#34;Hier klicken&#34;/&#62; Viel Spaß beim entwickeln : ) Dieser Beitrag stammt von Mario Priebe. Ähnliche Beiträge14. Februar 2011 -- TextTrimming &#8211; XAML Quicky14. Februar 2011 -- [...]]]></description>
			<content:encoded><![CDATA[<p>Stellt man einen Button auf &#8220;disabled&#8221;, wird leider kein Tooltip mehr angezeigt. Möchte man dem entgegenwirken, verwendet man die Methode ShowOnDisabled am ToolTipService:</p>
<p><a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGUvYmxvZy93cC1jb250ZW50L3VwbG9hZHMvMjAxMS8wMi8yMDExLTAyLTE0LTIwaDAyXzAyLnBuZw=="><img src="http://www.biggle.de/blog/wp-content/uploads/2011/02/2011-02-14-20h02_02.png" alt="" title="Tooltip Disabled Button" width="500" class="alignnone size-full wp-image-6262" /></a></p>

<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>Button Content<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Hier klicken&quot;</span> ToolTipService<span style="color: #339933;">.</span>ShowOnDisabled<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;True&quot;</span> IsEnabled<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;False&quot;</span> ToolTip<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Hier klicken&quot;</span><span style="color: #339933;">/&gt;</span></pre></td></tr></table></div>

<p>Viel Spaß beim entwickeln : )</p>
<p><br class="spacer_" /></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=6257" 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/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>28. Dezember 2011 -- <a href="http://www.biggle.de/blog/websequencediagrams-api-mit-net" title="WebSequenceDiagrams API mit .NET">WebSequenceDiagrams API mit .NET</a></li><li>5. Mai 2011 -- <a href="http://www.biggle.de/blog/prufen-ob-ein-string-eine-guid-ist" title="Prüfen ob ein String eine Guid ist">Prüfen ob ein String eine Guid ist</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></ul>]]></content:encoded>
			<wfw:commentRss>http://www.biggle.de/blog/tooltip-an-einem-disabled-button-xaml/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TextTrimming &#8211;  XAML Quicky</title>
		<link>http://www.biggle.de/blog/texttrimming-xaml-quicky</link>
		<comments>http://www.biggle.de/blog/texttrimming-xaml-quicky#comments</comments>
		<pubDate>Mon, 14 Feb 2011 18:58:34 +0000</pubDate>
		<dc:creator>Mario Priebe</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[CodeSnippet]]></category>
		<category><![CDATA[Quicky]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://www.biggle.de/blog/?p=6250</guid>
		<description><![CDATA[Im XAML hat man die Möchglichkeit den Text zu kürzen, wenn dieser länger ist, als die Oberfläche es zulässt. Man kann bestimmen, ob man nach einem Wort (WordEllipsis) und nach einem Buchstaben (CharacterEllipsis) den Text abtrennt. 3 Punkte (&#8230;) zeigen dem Benutzer an, das hier weiterer Text hinterlegt ist. 1 2 &#60;TextBlock Name=&#34;sampleTextBlock&#34; TextTrimming=&#34;WordEllipsis&#34; TextWrapping=&#34;NoWrap&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>Im XAML hat man die Möchglichkeit den Text zu kürzen, wenn dieser länger ist, als die Oberfläche es zulässt. </p>
<p><a href="http://www.biggle.de/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5iaWdnbGUuZGUvYmxvZy93cC1jb250ZW50L3VwbG9hZHMvMjAxMS8wMi8yMDExLTAyLTE0LTE5aDU2XzUzLnBuZw=="><img src="http://www.biggle.de/blog/wp-content/uploads/2011/02/2011-02-14-19h56_53.png" alt="" title="TextTrimming XAML WPF" width="350" height="92" class="alignnone size-full wp-image-6253" /></a></p>
<p>Man kann bestimmen, ob man nach einem Wort (WordEllipsis) und nach einem Buchstaben (CharacterEllipsis) den Text abtrennt. 3 Punkte (&#8230;) zeigen dem Benutzer an, das hier weiterer Text hinterlegt ist.</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: #339933;">&lt;</span>TextBlock  Name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;sampleTextBlock&quot;</span> TextTrimming<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;WordEllipsis&quot;</span>  TextWrapping<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;NoWrap&quot;</span> 
                    Text<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.&quot;</span><span style="color: #339933;">/&gt;</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=6250" 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>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>4. April 2010 -- <a href="http://www.biggle.de/blog/alle-bilder-eines-verzeichnisses-php-quicky" title="Alle Bilder eines Verzeichnisses &#8211; PHP Quicky">Alle Bilder eines Verzeichnisses &#8211; PHP Quicky</a></li><li>2. Januar 2010 -- <a href="http://www.biggle.de/blog/dynamisches-applikations-icon-xaml" title="Dynamisches Applikations Icon &#8211; XAML Quicky">Dynamisches Applikations Icon &#8211; XAML 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></ul>]]></content:encoded>
			<wfw:commentRss>http://www.biggle.de/blog/texttrimming-xaml-quicky/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Doppelklick im DataGrid abfangen &#8211; WPF Quicky</title>
		<link>http://www.biggle.de/blog/doppelklick-im-datagrid-abfangen-wpf-quicky</link>
		<comments>http://www.biggle.de/blog/doppelklick-im-datagrid-abfangen-wpf-quicky#comments</comments>
		<pubDate>Mon, 14 Feb 2011 18:48:34 +0000</pubDate>
		<dc:creator>Mario Priebe</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[CodeSnippet]]></category>
		<category><![CDATA[Quicky]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://www.biggle.de/blog/?p=6246</guid>
		<description><![CDATA[Möchte man auf den Klick eines Datensatzes  in einem WPF DataGrid reagieren, so kann man folgenden Code dazu verwenden: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 private void dataGrid_MouseDoubleClick&#40;object sender, MouseButtonEventArgs e&#41; &#123; DependencyObject dep = &#40;DependencyObject&#41;e.OriginalSource; &#160; while &#40;&#40;dep != null&#41; &#38;&#38; !&#40;dep [...]]]></description>
			<content:encoded><![CDATA[<p>Möchte man auf den Klick eines Datensatzes  in einem WPF DataGrid reagieren, so kann man folgenden Code dazu verwenden:</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> void dataGrid_MouseDoubleClick<span style="color: #009900;">&#40;</span>object sender<span style="color: #339933;">,</span> MouseButtonEventArgs e<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    DependencyObject dep <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>DependencyObject<span style="color: #009900;">&#41;</span>e<span style="color: #339933;">.</span>OriginalSource<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>dep <span style="color: #339933;">!=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span>dep is DataGridRow<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        dep <span style="color: #339933;">=</span> VisualTreeHelper<span style="color: #339933;">.</span>GetParent<span style="color: #009900;">&#40;</span>dep<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>dep <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
        <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>dep is DataGridRow<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        DataGridRow dataGridRow <span style="color: #339933;">=</span> dep <span style="color: #b1b100;">as</span> DataGridRow<span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//tu was</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Den Klick auf denDataGrid-ColumnHeader oder einer DataGrid-Zelle kann mit der selben Methode behandelt werden. Hier wird einfach die Abfrage mit in das if-Statement aufgenommen und im Rumpf dementsprechend behandelt.</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> void dataGrid_MouseDoubleClick<span style="color: #009900;">&#40;</span>object sender<span style="color: #339933;">,</span> MouseButtonEventArgs e<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    DependencyObject dep <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>DependencyObject<span style="color: #009900;">&#41;</span>e<span style="color: #339933;">.</span>OriginalSource<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>dep <span style="color: #339933;">!=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span>dep is DataGridRow<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span>dep is DataGridColumnHeader<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span>dep is DataGridCell<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        dep <span style="color: #339933;">=</span> VisualTreeHelper<span style="color: #339933;">.</span>GetParent<span style="color: #009900;">&#40;</span>dep<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>dep <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
        <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>dep is DataGridRow<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        DataGridRow dataGridRow <span style="color: #339933;">=</span> dep <span style="color: #b1b100;">as</span> DataGridRow<span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//tu was</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>dep is DataGridColumnHeader<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        DataGridColumnHeader columnHeader <span style="color: #339933;">=</span> dep <span style="color: #b1b100;">as</span> DataGridColumnHeader<span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//tu was</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>dep is DataGridCell<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        DataGridCell cell <span style="color: #339933;">=</span> dep <span style="color: #b1b100;">as</span> DataGridCell<span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//tu was</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<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=6246" 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/texttrimming-xaml-quicky" title="TextTrimming &#8211;  XAML Quicky">TextTrimming &#8211;  XAML 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/doppelklick-im-datagrid-abfangen-wpf-quicky/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

