- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在开始一个新项目,使用 ReactiveUI
和 MahApps.Metro
。我遇到的第一个障碍是 View 没有完整显示的问题。我有一个 Window
,在那个 Window
中我有一个来自 RxUI 库的 ViewModelViewHost
。它是嵌套 View 模型的简单容器。 ActiveItem 绑定(bind)已正确绑定(bind)到用户控件的 View 模型,并且用户控件中的 Button
在屏幕上可见。
我希望看到的是一个深灰色背景的窗口
,中间有一个按钮。我看到的是带有默认背景的 Window
和中间的 Button
。这个不对。如果我删除按钮,我在 Window
上什么也看不到,只有默认背景。
ViewModelViewHost
似乎只显示了 UserControl 的实际内容,而忽略了不被视为真正控件的内容,例如网格等。
有没有人遇到过这种行为?
<mah:MetroWindow x:Class="...MainWindow"
xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:rx="clr-namespace:ReactiveUI;assembly=ReactiveUI"
WindowStartupLocation="CenterScreen"
ShowTitleBar="False"
ShowCloseButton="False"
ShowMaxRestoreButton="False"
ShowMinButton="False"
Height="768"
Width="1024">
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<rx:ViewModelViewHost ViewModel="{Binding ActiveItem}" />
</Grid>
</mah:MetroWindow>
<UserControl x:Class="...NestedView"
Name="TheUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
TextOptions.TextHintingMode="Auto"
TextOptions.TextRenderingMode="Auto"
d:DesignHeight="768" d:DesignWidth="1024">
<Grid Background="DarkGray">
<Button Width="200" Height="100" />
</Grid>
</UserControl>
最佳答案
这不会是 ReactiveUI 问题,只是一个简单的 WPF 问题。
ViewModelViewHost
在您的窗口中居中。当您的 UserControl
设置了 DesignHeight
和 DesignWidth
时,当它在运行时呈现时,它会自动调整自身大小以适应其内容的高度和宽度 - 按钮
。
将 VerticalContentAlignment="Stretch"HorizontalContentAlignment="Stretch"
添加到您的 ViewModelViewHost
声明并删除其他两个 Alignment
属性(它们默认为Stretch),它应该将其内容拉伸(stretch)到 Window
的大小,同时将任何具有固定大小的项目居中。
关于c# - ReactiveUI - View 未正确呈现(或完整呈现),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29395102/
我的代码在下面,演示站点在这里:http://glimmer.rstudio.com/kdavenport/test1/ 第一个输入(下拉菜单)加载 global.R 中定义的数据框 第二个输入(下拉
我使用了一个可移植模板创建了一个 Xamarin 应用程序,并且我已经在可移植库和 Android 库中安装了响应式(Reactive) UI。但是,当我将应用程序部署到我的手机并导致触发 Raise
我有 WPF 列表框: 我喜欢使用后面的代码按名称绑定(bind) ListBox 的能力:this.OneWayBind(ViewModel, vm
我喜欢 ReactiveUI 的基于代码的绑定(bind)机制。但是,有时您需要使用 XAML 绑定(bind)。在这些情况下,需要在 View 和 ViewModel 之间正确设置 DataCont
在将我的项目中的 Xamarin Forms 包更新到 3.4.0.1009999 后,当使用 ReactiveUI x.DiscountSliderValue).Throttle(TimeSpan.
我正在测试 ReactiveUI,看起来很不错。 但是,我对 MessageBus 有点困惑。 示例代码: var bus = new MessageBus(); int result = -1; b
我无法在设计时在Visual Studio中使用ViewModelViewHost。这是设计使然还是我设置有误? 在我看来,我有: Locator.CurrentMutable.Initializ
我正在将 MvvmCross 与 ReactiveUI 进行比较,用于 Win Store、WP8、iOS、Droid 上的一个主要制药项目。我们已经选择了 Xamarin。 我对 ReactiveU
RX官方博客上有此example: var scheduler = new TestScheduler(); var xs = scheduler.CreateColdObservable(
ReactiveUI.Routing要求我们在Splat容器(Locator.CurrentMutable)中注册 View 。如果我未在Splat中注册,则无法正常工作。 如果我们正在使用其他一些I
所以,当我为我的系统开发新功能时,我也尝试做 TDD - 遗憾的是,现在对于旧功能来说代码太大了。 但是,我发现有时在测试过程中会遇到困难 - 特别是在使用 Delay 和 Throttle 时。 我
所以,当我为我的系统开发新功能时,我也尝试做 TDD - 遗憾的是,现在对于旧功能来说代码太大了。 但是,我发现有时在测试过程中会遇到困难 - 特别是在使用 Delay 和 Throttle 时。 我
我一直在研究在生产代码中使用响应式 UI 的可行性。有些功能确实很吸引人,但我担心依赖这个库。其中包括: 古怪的命名和约定。例如, protected 成员以小写字母开头,而 RaiseAndSetI
我正在将 WPF 应用程序移植到 Windows 应用商店应用程序。我有一些要放入可移植类库的 View 模型。该代码使用 reactui 框架。我创建了库,并使用 nuget 包管理器将 react
我通过 nuget 下载最新的 ReactiveUI (5.0.2) 到我基于 .NET 4.5 的项目。 我创建了具有一个属性的简单 View 模型类: using System; using Sy
在我使用 ReactiveUI 的 WPF 应用程序中,我注意到一个性能不佳的区域。 我有一个 View 模型,其中包含许多其他轻量级 View 模型(想想 30ish)。这些嵌套的 View 模型很
我有一个关于 reactiveui View 模型的问题。 我的 View 模型上有两个属性,月和年,并希望有一个进一步的输出属性 DateLabel,它将两者结合起来并很好地格式化,例如“2015
我查看了许多 ReactiveUI 示例,但我看不到一个很好的简单示例来说明如何处理异常,即应该向用户显示一条消息。 (如果有一个很好的例子,有人可以指点我吗?)。 我的第一个问题是如何使用 Reac
我有一个窗口使用 ReactiveUI Interaction 打开第二个窗口作为模态对话框,然后从第二个窗口中的 ListBox 返回数据。 问题是当 .ShowDialog() 完成时,ViewM
我有一个 WPF MVVM 应用程序。我的模型对象是我可以完全控制的 POCO。这些对象中的某些属性之间存在关系。 例如:假设我有 public class Model { public Ob
我是一名优秀的程序员,十分优秀!