我正在寻找链接ListBox中的选定项目上的笔记列与文本框。这个想法是当用户点击列表视图中的某个项目时,他们可以更改关于该项目的注释。稍后,我可以在保存时使用针对此项目保存的注释。笔记标题是隐藏的。WPF链接列表查看与文本框选定的项目
正如您在下面的图片中看到的,我已经选择了列表中的项目,并且所有选定的值都通过了文本框。
- 我只希望AttachmentNotes才能通过
- 我希望能够改变这些笔记,然后将更新所选项目的结合。
下面是我的WPF代码:
<ListView x:Name="LstAttachments" HorizontalAlignment="Left" Height="137" Margin="10,83,0,0" VerticalAlignment="Top" Width="641">
<ListView.View>
<GridView>
<GridViewColumn Header="Attachment Name" Width="400" DisplayMemberBinding="{Binding AttachmentName}"/>
<GridViewColumn Header="" Width="0" DisplayMemberBinding="{Binding AttachmentPath}"/>
<GridViewColumn Header="Attachment Type" Width="237" DisplayMemberBinding="{Binding AttachmentType}"/>
<GridViewColumn Header="Notes" Width="0" DisplayMemberBinding="{Binding AttachmentNotes}"/>
</GridView>
</ListView.View>
</ListView>
<TextBox x:Name="TxtAttachmentNotes" Text="{Binding SelectedValue, ElementName=LstAttachments}" HorizontalAlignment="Left" Height="133" Margin="10,235,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="641" SpellCheck.IsEnabled="True" MaxLength="25000"/>
项目添加到ListView像这样:
//Display the File Name and Type in the ListBox
LstAttachments.Items.Add(new { AttachmentName = RibbonTest.attfilename, AttachmentPath = RibbonTest.attfilename, AttachmentType = RibbonTest.attfiletype, AttachmentNotes = "Test Notes Blah Blah" });
所有帮助深表感谢。 :)
谢谢
正如你在我试图用绑定文本框ListView控件选择的值的示例代码中看到并带回所有的值。我知道我可以将它设置为TwoWay来保存信息。不过,我只想能够编辑AttachmentNotes值 – LiveKarma