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 DataGridTemplat eColumn,in edit mode it's consist of a text box and list box as below
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 UpdateSourceTri gger="Explicit" and i added a handler for the text box lost focus and its handler is "txtBoxTemp_Los tFocus", i have added the following code in the handler
be noted that bindExpres is pre-defined at the beging of the class,and the handler for the add button as below
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
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 DataGridTemplat eColumn,in edit mode it's consist of a text box and list box as below
Code:
[LEFT]
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<StackPanel>
<DockPanel Style="{StaticResource DockPanstyle}">
<Button Name="addConBut" DockPanel.Dock="Left" Click="addConBut_Click" Style="{StaticResource ButStyle}" Template="{StaticResource addButCT}"/>
<Button Name="delConBut" DockPanel.Dock="Right" Click="delConElementBut_Click" Style="{StaticResource ButStyle}" Template="{StaticResource delButCT}"/>
</DockPanel>
<TextBox Name="hTxtBox" Margin="2,6" LostFocus="txtBoxTemp_LostFocus" >
<TextBox.Text>
<MultiBinding Converter="{StaticResource mulBindConv}" UpdateSourceTrigger="Explicit">
<Binding Path="AddHomeNumber" ValidatesOnDataErrors="True" ValidatesOnExceptions="True" NotifyOnValidationerror="True" Mode="OneWayToSource">
<Binding.ValidationRules>
<MyClasses:ContactValidation CheckFor="Home"></MyClasses:ContactValidation>
</Binding.ValidationRules>
</Binding>
<Binding ElementName="hnList" Path="SelectedItem" Mode="OneWay"></Binding>
</MultiBinding>
</TextBox.Text>
</TextBox>
<ListBox Name="hnList" ItemsSource="{Binding HomeNumbers}" DisplayMemberPath="HPhone" IsSynchronizedWithCurrentItem="True" />
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>[/LEFT]
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 UpdateSourceTri gger="Explicit" and i added a handler for the text box lost focus and its handler is "txtBoxTemp_Los tFocus", i have added the following code in the handler
Code:
TextBox templ_txt_Bx = e.Source as TextBox; bindExpres=templ_txt_Bx.GetBindingExpression(TextBox.TextProperty);
Code:
if (bindExpres != null)
{
bindExpres.UpdateSource();
}
bindExpres always equal null and i don't know why,does any one know why and how can i solve this issue