<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: LostFocus (TextBox) vs. Buttons IsDefault-Property</title>
	<link>http://www.thomasclaudiushuber.com/blog/2008/05/02/lostfocus-textbox-vs-buttons-isdefault-property/</link>
	<description>Thomas Claudius Huber (by friends just called ::: hubethom :::)</description>
	<pubDate>Wed, 07 Jan 2009 05:25:54 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: hubethom</title>
		<link>http://www.thomasclaudiushuber.com/blog/2008/05/02/lostfocus-textbox-vs-buttons-isdefault-property/#comment-852</link>
		<dc:creator>hubethom</dc:creator>
		<pubDate>Tue, 06 May 2008 06:47:52 +0000</pubDate>
		<guid>http://www.thomasclaudiushuber.com/blog/2008/05/02/lostfocus-textbox-vs-buttons-isdefault-property/#comment-852</guid>
		<description>Hi Karl,

yes, it's a real monster. But the monster becomes your best friend with bindingexpression. :-)

Thanks a lot for your code snippet.</description>
		<content:encoded><![CDATA[<p>Hi Karl,</p>
<p>yes, it&#8217;s a real monster. But the monster becomes your best friend with bindingexpression. <img src='http://www.thomasclaudiushuber.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Thanks a lot for your code snippet.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karl Shifflett</title>
		<link>http://www.thomasclaudiushuber.com/blog/2008/05/02/lostfocus-textbox-vs-buttons-isdefault-property/#comment-802</link>
		<dc:creator>Karl Shifflett</dc:creator>
		<pubDate>Sat, 03 May 2008 10:43:45 +0000</pubDate>
		<guid>http://www.thomasclaudiushuber.com/blog/2008/05/02/lostfocus-textbox-vs-buttons-isdefault-property/#comment-802</guid>
		<description>Thomas,

Nice work!   Yep, I ran into this monster too!

In Part 2 of my WPF series: http://www.codeproject.com/KB/WPF/WPFBusinessAppsPartTwo.aspx  I ran into this and it drover me nuts until I figured out what was up.

Below is a code snippet from the article.  The UpdateFocusedField method is actually place in the base class of the UserControl that hosts all my forms.


Private Sub btnSave_Click(ByVal sender As Object, _
                            ByVal e As System.Windows.RoutedEventArgs) _
          Handles btnSave.Click
    
    UpdateFocusedField()

    If _objCustomer.IsValid Then
      Me.frmNotification.NotificationMessage = "Customer record saved"
    End If

  End Sub


  Private Sub UpdateFocusedField()

    Dim fwE As FrameworkElement = _
      TryCast(Keyboard.FocusedElement, FrameworkElement)

    If fwE IsNot Nothing Then

      Dim expression As BindingExpression = Nothing

      If TypeOf fwE Is TextBox Then
        expression = fwE.GetBindingExpression(TextBox.TextProperty)
        'TODO add more controls types here.  Won't be that many.
      End If

      If expression IsNot Nothing Then
        expression.UpdateSource()
      End If

    End If

  End Sub

Cheers,

Karl</description>
		<content:encoded><![CDATA[<p>Thomas,</p>
<p>Nice work!   Yep, I ran into this monster too!</p>
<p>In Part 2 of my WPF series: <a href="http://www.codeproject.com/KB/WPF/WPFBusinessAppsPartTwo.aspx" rel="nofollow">http://www.codeproject.com/KB/WPF/WPFBusinessAppsPartTwo.aspx</a>  I ran into this and it drover me nuts until I figured out what was up.</p>
<p>Below is a code snippet from the article.  The UpdateFocusedField method is actually place in the base class of the UserControl that hosts all my forms.</p>
<p>Private Sub btnSave_Click(ByVal sender As Object, _<br />
                            ByVal e As System.Windows.RoutedEventArgs) _<br />
          Handles btnSave.Click</p>
<p>    UpdateFocusedField()</p>
<p>    If _objCustomer.IsValid Then<br />
      Me.frmNotification.NotificationMessage = &#8220;Customer record saved&#8221;<br />
    End If</p>
<p>  End Sub</p>
<p>  Private Sub UpdateFocusedField()</p>
<p>    Dim fwE As FrameworkElement = _<br />
      TryCast(Keyboard.FocusedElement, FrameworkElement)</p>
<p>    If fwE IsNot Nothing Then</p>
<p>      Dim expression As BindingExpression = Nothing</p>
<p>      If TypeOf fwE Is TextBox Then<br />
        expression = fwE.GetBindingExpression(TextBox.TextProperty)<br />
        &#8216;TODO add more controls types here.  Won&#8217;t be that many.<br />
      End If</p>
<p>      If expression IsNot Nothing Then<br />
        expression.UpdateSource()<br />
      End If</p>
<p>    End If</p>
<p>  End Sub</p>
<p>Cheers,</p>
<p>Karl</p>
]]></content:encoded>
	</item>
</channel>
</rss>
