473,387 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

GetBindingExpression(TextBox.TextProperty) issue

Hi every Body
I'm coding a Phone book manger C# WPF application,it consist of a data grid which is bind to observal collection
one of the data grid columnis is DataGridTemplateColumn,in edit mode it's consist of a text box and list box as below
Expand|Select|Wrap|Line Numbers
  1. <DataGridTemplateColumn.CellEditingTemplate>
  2. <DataTemplate>
  3.   <StackPanel>
  4.      <DockPanel  Style="{StaticResource DockPanstyle}">
  5.        <Button Name="addConBut" DockPanel.Dock="Left"  Click="addConBut_Click" Style="{StaticResource ButStyle}" Template="{StaticResource addButCT}"/>
  6.  
  7. <Button Name="delConBut" DockPanel.Dock="Right" Click="delConElementBut_Click" Style="{StaticResource ButStyle}" Template="{StaticResource delButCT}"/>
  8.       </DockPanel>
  9.  
  10. <TextBox Name="hTxtBox" Margin="2,6" LostFocus="txtBoxTemp_LostFocus" >
  11. <TextBox.Text>
  12.                                         <MultiBinding Converter="{StaticResource mulBindConv}" UpdateSourceTrigger="Explicit">
  13.  
  14. <Binding Path="AddHomeNumber" ValidatesOnDataErrors="True" ValidatesOnExceptions="True" NotifyOnValidationerror="True" Mode="OneWayToSource">
  15.                                                 <Binding.ValidationRules>
  16.                                                      <MyClasses:ContactValidation CheckFor="Home"></MyClasses:ContactValidation>
  17.                                                 </Binding.ValidationRules>
  18.                                             </Binding>
  19.  
  20. <Binding ElementName="hnList" Path="SelectedItem" Mode="OneWay"></Binding>
  21.                                         </MultiBinding>
  22. </TextBox.Text>
  23. </TextBox>
  24. <ListBox Name="hnList" ItemsSource="{Binding HomeNumbers}"  DisplayMemberPath="HPhone" IsSynchronizedWithCurrentItem="True" />
  25. </StackPanel>
  26.  </DataTemplate>
  27.  </DataGridTemplateColumn.CellEditingTemplate>
in the edit TextBox which its name is "hTxtBox" i have used Multi Binding,every thing is ok except one thing ,
i want the source to be updated when pressing the add button not when the editing TextBox or the entire row of the DataGrid Lost Focus, so i set UpdateSourceTrigger="Explicit" and i added a handler for the text box lost focus and its handler is "txtBoxTemp_LostFocus", i have added the following code in the handler
Expand|Select|Wrap|Line Numbers
  1. TextBox templ_txt_Bx = e.Source  as TextBox;
  2. bindExpres=templ_txt_Bx.GetBindingExpression(TextBox.TextProperty);
  3.  
be noted that bindExpres is pre-defined at the beging of the class,and the handler for the add button as below

Expand|Select|Wrap|Line Numbers
  1. if (bindExpres != null)
  2.           {
  3.               bindExpres.UpdateSource();
  4.           }
  5.  
my problem is
bindExpres always equal null and i don't know why,does any one know why and how can i solve this issue
Jan 8 '12 #1
0 1719

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: HenrikL | last post by:
Hi. I have a textbox that have a binding on it with converter and validationrules. When a validation error ouccur the foreground of the textbox will change to red cause it has a style.triggers...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.