<i id='bavqi'><tr id='bavqi'><dt id='bavqi'><q id='bavqi'><span id='bavqi'><b id='bavqi'><form id='bavqi'><ins id='bavqi'></ins><ul id='bavqi'></ul><sub id='bavqi'></sub></form><legend id='bavqi'></legend><bdo id='bavqi'><pre id='bavqi'><center id='bavqi'></center></pre></bdo></b><th id='bavqi'></th></span></q></dt></tr></i><div id='bavqi'><tfoot id='bavqi'></tfoot><dl id='bavqi'><fieldset id='bavqi'></fieldset></dl></div>
<legend id='bavqi'><style id='bavqi'><dir id='bavqi'><q id='bavqi'></q></dir></style></legend>

      <bdo id='bavqi'></bdo><ul id='bavqi'></ul>

    <small id='bavqi'></small><noframes id='bavqi'>

    <tfoot id='bavqi'></tfoot>

        WPF ListBox 按钮选定项

        WPF ListBox Button Selected Item(WPF ListBox 按钮选定项)
        1. <legend id='80cux'><style id='80cux'><dir id='80cux'><q id='80cux'></q></dir></style></legend>

              <small id='80cux'></small><noframes id='80cux'>

                <bdo id='80cux'></bdo><ul id='80cux'></ul>
                <tfoot id='80cux'></tfoot>

                  <i id='80cux'><tr id='80cux'><dt id='80cux'><q id='80cux'><span id='80cux'><b id='80cux'><form id='80cux'><ins id='80cux'></ins><ul id='80cux'></ul><sub id='80cux'></sub></form><legend id='80cux'></legend><bdo id='80cux'><pre id='80cux'><center id='80cux'></center></pre></bdo></b><th id='80cux'></th></span></q></dt></tr></i><div id='80cux'><tfoot id='80cux'></tfoot><dl id='80cux'><fieldset id='80cux'></fieldset></dl></div>
                    <tbody id='80cux'></tbody>
                  本文介绍了WPF ListBox 按钮选定项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个带有一些文本块和一个按钮的列表框——在按钮的代码隐藏中,它调用了一个传递当前选定列表框项目的方法,这很好用.问题是,当我选择一个项目然后单击另一个项目上的按钮时,它不会更新SelectedItem"属性——有没有一种 Xaml 或 C# 可以强制单击按钮以选择父 ListBoxItem?

                  I have a listbox with some textblocks and a button -- in the button's codebehind it calls a method passing the currently selected listbox item, this works great. The issue is that when I select an item and then click the button on another item it doesn't update the "SelectedItem" property -- is there a way Xaml or C# that I can force a button click to select the parent ListBoxItem?

                  Xaml

                  <DataTemplate>
                      <Grid>
                          <Button x:Name="myButton" Click="myButton_Click" Height="30" Width="30">
                              <Image Source="ResourcesImage.png" />
                          </Button>
                          <TextBlock Text="{Binding DataField}"></TextBlock>
                      </Grid>
                  </DataTemplate>
                  

                  推荐答案

                  var curItem = ((ListBoxItem)myListBox.ContainerFromElement((Button)sender)).Content;
                  

                  这篇关于WPF ListBox 按钮选定项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Populate ListBox with a IEnumrable on another thread (winforms)(在另一个线程(winforms)上使用 IEnumrable 填充 ListBox)
                  listbox selected item give me quot; System.Data.DataRowViewquot; , C# winforms(列表框选择的项目给我quot;System.Data.DataRowView, C# Winforms)
                  Cannot remove items from ListBox(无法从列表框中删除项目)
                  Preventing ListBox scrolling to top when updated(更新时防止列表框滚动到顶部)
                  Drag and drop from list to canvas on windows phone with MVVM(使用 MVVM 在 Windows 手机上从列表拖放到画布)
                  Deselection on a WPF listbox with extended selection mode(具有扩展选择模式的 WPF 列表框上的取消选择)
                  • <i id='GeAVh'><tr id='GeAVh'><dt id='GeAVh'><q id='GeAVh'><span id='GeAVh'><b id='GeAVh'><form id='GeAVh'><ins id='GeAVh'></ins><ul id='GeAVh'></ul><sub id='GeAVh'></sub></form><legend id='GeAVh'></legend><bdo id='GeAVh'><pre id='GeAVh'><center id='GeAVh'></center></pre></bdo></b><th id='GeAVh'></th></span></q></dt></tr></i><div id='GeAVh'><tfoot id='GeAVh'></tfoot><dl id='GeAVh'><fieldset id='GeAVh'></fieldset></dl></div>
                    • <tfoot id='GeAVh'></tfoot>

                          <tbody id='GeAVh'></tbody>
                        <legend id='GeAVh'><style id='GeAVh'><dir id='GeAVh'><q id='GeAVh'></q></dir></style></legend>

                            <bdo id='GeAVh'></bdo><ul id='GeAVh'></ul>

                            <small id='GeAVh'></small><noframes id='GeAVh'>