<small id='0SUzZ'></small><noframes id='0SUzZ'>

    <tfoot id='0SUzZ'></tfoot>

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

        如何在不违反 MVVM 原则的情况下处理拖放?

        时间:2023-08-25
        <i id='iEkeo'><tr id='iEkeo'><dt id='iEkeo'><q id='iEkeo'><span id='iEkeo'><b id='iEkeo'><form id='iEkeo'><ins id='iEkeo'></ins><ul id='iEkeo'></ul><sub id='iEkeo'></sub></form><legend id='iEkeo'></legend><bdo id='iEkeo'><pre id='iEkeo'><center id='iEkeo'></center></pre></bdo></b><th id='iEkeo'></th></span></q></dt></tr></i><div id='iEkeo'><tfoot id='iEkeo'></tfoot><dl id='iEkeo'><fieldset id='iEkeo'></fieldset></dl></div>

        1. <tfoot id='iEkeo'></tfoot>
              <tbody id='iEkeo'></tbody>

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

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

              • <legend id='iEkeo'><style id='iEkeo'><dir id='iEkeo'><q id='iEkeo'></q></dir></style></legend>

                  本文介绍了如何在不违反 MVVM 原则的情况下处理拖放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  目前我的 XAML 中有

                  Currently I have in my XAML

                  <TabControl  
                      AllowDrop="True"
                      PreviewDragOver="DragOver"
                      PreviewDrop="Drop" />
                  

                  我所有的拖放代码都存在于我的 View 的代码隐藏中,而不是我的 ViewModel 中.

                  All of my drag/drop code exists within the codebehind of my View, rather than within my ViewModel.

                  如何在 ViewModel 中处理拖放操作而不在 View 上添加任何依赖项?

                  How can I handle drag/drop in my ViewModel without adding any dependencies on the View?

                  推荐答案

                  有这样的库,例如 gong 以及各种博客文章中的类似片段.

                  There are libraries for this such as gong and similar snippets on various blog articles.

                  但是,您不应该过于拘泥于完全没有代码隐藏.例如,这仍然是我书中的 MVVM:

                  However, you shouldn't get too hung up on having absolutely no code-behind. For example, this is still MVVM in my book:

                  void ButtonClicked(object sender, EventArgs e)
                  {
                      ((MyViewModel) this.DataContext).DoSomething();
                  }
                  

                  命令绑定可能是更好的选择,但逻辑肯定在视图模型中.使用诸如拖放之类的东西,您想在哪里画线会更加多变.您可以在适当的时候让代码隐藏解释 Drag Args 并调用视图模型上的方法.

                  A command binding might be a better choice, but the logic is definitely in the viewmodel. With something like Drag and Drop, it's more variable where you want to draw the line. You can have code-behind interpret the Drag Args and call methods on the viewmodel when appropriate.

                  这篇关于如何在不违反 MVVM 原则的情况下处理拖放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用 Selenium 和 C# 在 draggable=true 时拖放不工作 下一篇:C#拖放文件形成

                  相关文章

                  最新文章

                      <bdo id='bKtZT'></bdo><ul id='bKtZT'></ul>
                  1. <small id='bKtZT'></small><noframes id='bKtZT'>

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

                      <legend id='bKtZT'><style id='bKtZT'><dir id='bKtZT'><q id='bKtZT'></q></dir></style></legend>

                      <tfoot id='bKtZT'></tfoot>