我正在尝试在ViewModel的构造函数中创建一个ReactiveCommand:
environments:
development:
dataSource:
dbCreate: none
url: jdbc:h2:./devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
test:
dataSource:
dbCreate: update
url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
production:
dataSource:
dbCreate: update
url: jdbc:h2:./prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
然后将ConvertCmd绑定到我的GUI中按钮的Command属性
[Files]
Source: "D:\POS CAD Standard\CAD\*"; DestDir: "C:\POS CAD Standard"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "D:\POS CAD Standard\acad.lsp"; DestDir: "{userappdata}\Autodesk\AutoCAD 2014\R19.1\enu\support"; Flags: ignoreversion
[Dirs]
Name: "C:\POS CAD Standard"; Attribs:readonly hidden system; Permissions: users-readexec;Flags:
[Icons]
Name: "{group}\{cm:UninstallProgram,POS CAD Standard}"; Filename: "{uninstallexe}"
但是,GUI按钮保持灰色并且永远不会启用
有几点需要注意:
我在这里亏本。有没有人知道为什么按钮永远不会在我的原始场景中启用?
答案 0 :(得分:0)
像往常一样,在这个问题上花了好几个小时之后,我发布这个帖子后立即找到了自己的答案......
似乎这是一个线程问题。 订阅在未知的,可能变化的线程上执行。以下修复了代码 - 尽管说实话,我不完全确定为什么有必要在Dispatcher上运行。
IObservable<bool> canExecute = this
.WhenAnyValue(x => x.InsertableItems, x => x.IsRefreshing,
(insertableItems, isRefreshing) => !isRefreshing && insertableItems > 0)
.ObserveOnDispatcher(); // this fixes the issue