Wpf列表框到文本框绑定 [英] Wpf listbox to textbox binding

查看:83
本文介绍了Wpf列表框到文本框绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将listbox seleceted item绑定到textbox当点击我得到这样的

Hi , I want to bind listbox seleceted item to textbox when click i got like this

System.Windows.Controls.ListBoxItem:

如何修剪或者如果有任何替代方式只是让我知道。



提前致谢



我试过的:



how to trim that or if there any alternate way just let me know.

Thanks in Advance

What I have tried:

txtName.Text = List.SelectedValue.ToString();

推荐答案

嗨。

hi .
<Grid>
        
        <TextBox Text="{Binding ElementName=LB,Path=SelectedItem.Title}" BorderBrush="Gray" Height="23" Width="80" VerticalAlignment="Top" HorizontalAlignment="Left"/>
        
      
        
        <ListBox x:Name="LB" Margin="0 50 0 0">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Title}"/>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        
    </Grid>


这篇关于Wpf列表框到文本框绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆