在wpf中将listView值的Assaign文本框转换为变量 [英] Assaign textbox of listView value to variable in wpf
本文介绍了在wpf中将listView值的Assaign文本框转换为变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我需要将listView值的Assaign文本框更改为变量.
我已使用这些XAML代码创建listView.
Hi All,
I need to Assaign textbox of listView value to variable.
I have use these XAML code to create listView.
<ListView x:Name="listV_EmpAttendence" ItemsSource="{Binding}">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<EventSetter Event="GotFocus" Handler="Item_Got_Focus_listAttendence"/>
</Style>
</ListView.ItemContainerStyle>
<ListView.View>
<GridView>
<GridViewColumn Header="Value1">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox x:Name="txt_Value1"
Text="{Binding Path=Value1}/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
我需要这样,
字符串textValue = txt_Value1
我该怎么办.请告诉我.
谢谢,
Chamara.
I need to do like this,
string textValue=txt_Value1
How can I do it.Please let me know.
Thanks,
Chamara.
推荐答案
I could find solution to this problem.
step 1
Need to set lostFocus event to txt_Value1.
<TextBox x:Name="txt_Value1" Text="{Binding Path=Value1}" LostFocus="txt_Value1_LostFocus" />
Steep 2
In C# code,
private void txt_Value1_LostFocus(object sender, RoutedEventArgs e)
{
string textValue= ((TextBox)sender).Text;
}
谢谢.
Thanks.
这篇关于在wpf中将listView值的Assaign文本框转换为变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文