Tom*_*han 11 xaml reactiveui windows-phone-8.1
我有一个继承ReactiveObject自reactiveui.net的视图模型,类似于
public sealed class TestViewModel : ReactiveObject
{
public sealed class NestedViewModel
{
private string _property;
public string VMProperty
{
get { return _property; }
set { this.RaiseAndSetIfChanged(ref _property, value); }
}
private string _suffix;
public string Suffic
{
get { return _suffix; }
set { this.RaiseAndSetIfChanged(ref _suffix, value); }
}
}
private NestedViewModel _nested = new NestedViewModel();
public Nested
{
get { return _nested; }¨
set { this.RaiseAndSetIfChanged(ref _nested, value); }
}
#if DEBUG
public TestViewModel() {
Nested.VMProperty = "Test string";
Nested.Suffix = "with suffix";
}
#endif
}
Run Code Online (Sandbox Code Playgroud)
我可以得到以下内容来显示设计时和运行时:
<Page.DataContext>
<local:TestViewModel />
</Page.DataContext>
<TextBlock Text="{Binding Nested.VMProperty}" />
<TextBlock Text="{Binding Nested.Suffix}" />
Run Code Online (Sandbox Code Playgroud)
但是当我尝试这样做时,设计时没有显示任何文字:
<Page.DataContext><!-- ... -->
<TextBlock>
<Run Text="{Binding Nested.VMProperty}" />
<Run Text="{Binding Nested.Suffix}" />
</TextBlock>
Run Code Online (Sandbox Code Playgroud)
运行时它仍然有效,但我不想每次要检查一些像素推送时都要部署到设备模拟器...
如何<Run />在设计时在标签内显示这些属性?