English 中文(简体)
WPF MVLT 指挥:多个指挥参数
原标题:WPF MVVM Commands: Multiple Command Parameters

也许我的问题比起功能问题更是建筑问题,但我正试图把案文Box约束在指挥中,也就是通过多种参数(即习惯目标)。 不知道如何以声明方式(xaml)做到这一点。

ViewA (sits on top of ViewModelA) it has a TextBox, which is bound to CommandX

ViewB (sits on top of ViewModelB) (this is in fact another user control within the same Window as ViewA) When commandX fires, ViewModelB needs to execute some method. ViewModelB needs to be 更新d with multiple properties before it can execute that method.

我的问题是,如何组织我的指挥/领导,使Giudm B掌握足够的信息,以执行其方法。

注: A拥有实施其方法所需的一切手段。 但是,我不想从那里得到,因为后来一度想要指挥。 十. 从不同观点执行

更新

看来,我可以单独确定指挥官财产,这可能属于Gis ModelA的复杂类别。 这应当足以把所有必要的财产装入其中。

we

工作! 这里,我的公墓财产就我的看法。

    public ExecuteQueryCommandParameters ExecuteQueryParameters {
        get {
            var p = new ExecuteQueryCommandParameters();
            p.AllColumns = ColumnsMaster;
            p.DatabaseName = SelectedDatabase;
            p.ServerName = SelectedServer;
            p.TopRows = 20;
            p.ViewModelName = "MainDataView";

            return p;
        }
    }

内容提要

<Button Command="{Binding ExecuteQuery}" CommandParameter="{Binding ExecuteQueryParameters}">Top 20</Button>

更新

这一解决办法有小的路段。 指挥参数受财产约束。 但它在装货时收回,而不是在指挥时收回。 我需要在指挥执行时间这样做,以便所有财产都有最新的价值。 任何关于如何实现这一目标的想法?

问题回答

在此,我将如何这样做:

为了这一解释,我假定所有必要的信息都属于一个类别,即“我的客户界限”。

我还认为,你的XAML将主要母子控制数据编成对Gis ModelA具有约束力的数据。

1. 观点 暴露了MyCustomCommandParailes类型的财产。

Then, on ViewB, create a DependencyProperty of a type MyCustomCommandParameters. The handlers for this property would pass this information to ViewModelB.

在XAML中,将“MyCustomCommandParailes”的价值与“MyCustomCommandParailes”财产挂钩。

It s a bit of one-off plumbing work, but then you would meet your goal of having the information passed from ViewModelA to ViewModelB by XAML binding, and the two models would not know about one another.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签