小编Tom*_*ier的帖子

ReactiveUI 使用 WhenAny 观察 Collection 并分配布尔值 PropertyHelper

我有一个 ObservableCollection 包含我想观察的字符串。当第一个索引发生变化时,我想更新一个 ObservableAsPropertyHelper 布尔变量,如果该索引处的字符串不为空且不为空,则将其设置为 true。或者,将 Collection 转换为包含 bool 的第二个 ObservableCollection 的方法也可以。
这是我尝试过的:

public ObservableCollection<string> Difficulties { get; set; }
public extern bool Easy { [ObservableAsProperty] get; }

public Song()
{
    this.WhenAny(x => x.Easy, x => x.GetValue()[0] != null && x.GetValue()[0}]!= "").ToPropertyEx(this, x => x.Easy);
}
Run Code Online (Sandbox Code Playgroud)

我尝试了上面的代码,因为它适用于类似的示例:

[Reactive] public string Title { get; set; }
public extern bool Enabled { [ObservableAsProperty] get; }

public Song()
{
   this.WhenAny(x => x.Title, x => x.GetValue() != null && x.GetValue() != "").ToPropertyEx(this, x => …
Run Code Online (Sandbox Code Playgroud)

c# linq lambda list reactiveui

2
推荐指数
1
解决办法
2196
查看次数

标签 统计

c# ×1

lambda ×1

linq ×1

list ×1

reactiveui ×1