合并依赖属性

buc*_*ley 1 wpf dependency-properties mvvm-light caliburn.micro reactiveui

我现在已经做了一些WPF项目并且看到弹出相同的问题,这是聚合/组合依赖属性(dp)的"问题".

例如,我有10 dp的bool类型,我希望将其组合并作为单独的dp公开.除非一个或多个成分是假的,否则组合的dp是真的.

我目前使用addValueChanged执行此操作,它为10(!()dp中的每一个注册回调,但我想知道是否有更优雅的解决方案或可能是解决此常见情况的框架.我还没有使用reactiveUI和mvvm light但我认为它在这里很有用.

        var dpd = DependencyPropertyDescriptor.FromProperty(property,
                                                            owner.GetType());
        dpd.AddValueChanged(owner,
                            handler);
Run Code Online (Sandbox Code Playgroud)

Ana*_*tts 5

在ReactiveUI中,这是:

// etc all the way to ten
this.WhenAny(x => x.PropOne, x => PropTwo, x => x.PropThree, 
    (one,two,three) => one && two && three)
    .Subscribe(x => FinalProp = x);
Run Code Online (Sandbox Code Playgroud)