- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我很难获得一个基本的 MvvmCross Android 示例,其中 RelativeLayout 的 BackgroundColor 绑定(bind)到 ViewModel。
应用程序运行,出现一些文本,我希望我的背景变成黄色。但是,背景颜色保持不变。
我在我的 Core 和 Droid 项目以及 MvvmCross - Color 插件中都包含了 Hot Tuna 入门包。我的 Droid 项目自动获得了 ColorPluginBootstrap.cs
布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
local:MvxBind="BackgroundColor NativeColor(BackgroundColor)">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textSize="20sp"
android:gravity="center"
android:text="Text to make sure the layout inflates" />
</RelativeLayout>
View 模型
public class ViewModel : MvxViewModel
{
RGBAColorConverter _rgbaConverter;
public ViewModel()
{
var color = "#ffedff00";
_rgbaConverter = new RGBAColorConverter();
BackgroundColor = _rgbaConverter.Convert(color);
}
private MvxColor _backgroundColor;
public MvxColor BackgroundColor
{
get { return _backgroundColor; }
set
{
_backgroundColor = value;
RaisePropertyChanged(() => BackgroundColor);
}
}
}
绑定(bind)有效 - 我尝试制作其他字符串形式的 ViewModel 属性来执行简单的文本绑定(bind)。所有这一切似乎都很好。
我在 BackgroundColor ViewModel 属性的 getter 上放置了调试断点,我可以按预期看到 MvxColor。
我的颜色绑定(bind)方案缺少什么?
Setup.cs
中做任何额外的事情最佳答案
我刚刚编写了一个测试应用程序,它似乎对我有用 - 使用 3.0.14 nuget 二进制文件。
此外,ValueConverters 测试应用程序似乎工作正常 - https://github.com/MvvmCross/MvvmCross-Tutorials/tree/master/ValueConversion
看着你的样本,我唯一能想到的是,也许你只是在测试透明颜色(RGBA #ffedff00 的 Alpha=0)
如果不是,您能否发布更多内容 - 也许是某处的完整样本?
关于android - MvvmCross Android BackgroundColor 未绑定(bind)到 ViewModel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20169906/
我想使用 JavaScript 将 #Content.backgroundColor 更改为 elem.backgroundColor。 这里是 HTML 代码: Btn1 Btn2 Btn3 这是
@implementation AVSuperView - (AVSuperView*)initWithFrame:(CGRect)frame{ if (self = [super initW
这两行 Swift 代码在功能上有区别吗? self.button.layer.backgroundColor = UIColor.whiteColor().CGColor 和 self.button
我正在尝试学习 React.JS,但有些事情让我大吃一惊。 我有这个标题组件: class Header extends Component { render() { return ;
我正在尝试学习 React.JS,但有些事情让我大吃一惊。 我有这个标题组件: class Header extends Component { render() { return ;
我正在尝试为事件添加背景颜色,但没有运气。 $('#calendar').fullCalendar('renderEvent', { id: 1, title: 'hello', start: sel
这是在iOS 9中。我无法设置SKView的背景颜色,它始终以默认的灰色呈现。有没有解决的办法? let frame = CGRect(x: 0, y: 0, width: 200, height:
我正在创建一个 SWRevealView Controller ,每当我使用 self.view.backgroundColor 或实例化一个新的 View Controller 并使用 UIView
我正在尝试向使用 backgroundColor 的层添加高斯模糊。 下面的代码在标题文本周围添加了一个框并且工作正常,我只是想让白色变得模糊。 title.layer.borderColor = U
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 关闭 4 年前。 这个问题是由于打字错误或无法再重现的问题引起的。虽然类似的问题可能是on-topic
为什么在 CSS 中通过 Javascript 更改样式时使用 background-color 不起作用? 这个有效: document.getElementById("circ").style.b
我有下面的 javascript 函数,当一个新文档被添加到列表时,它会闪烁链接的 bg 3 次。 这第一次工作正常,但随后对该函数的调用导致闪烁变得困惑。越叫越怪异的闪烁行为。 我在 IE8 和最新
如果我在属性检查器的图像/ ImageView 中设置图像,则以下后续调用不起作用: picture.backgroundColor = UIColor.greenColor() 如果我在代码中设置图
我正在尝试制作一个网站,但遇到了问题。当我在 Chrome 中运行它时,我得到:“无法设置未定义的属性‘backgroundColor’”。我不明白为什么我会得到这个。我的 var 不是数组(只是一个
我在我的应用程序中使用新的(在 iOS 7 中)UIPopoverController.backgroundColor 设置来根据需要更改弹出框的颜色,但我发现使用此设置会导致每当我打开我的popov
我有以下控制权。我想更改某些事件触发器的背景颜色。我想将此 clrGray 资源设为某些事件点击时的颜色。 我试过以下方法,但没有用:( XAM: CS: //On Some event /
我有以下控制权。我想更改某些事件触发器的背景颜色。我想将此 clrGray 资源设为某些事件点击时的颜色。 我试过以下方法,但没有用:( XAM: CS: //On Some event /
我正在构建一个排序算法可视化工具。这些项目中的每一项都是 div,backgroundColor 设置为白色。 当算法运行时,他将 backgroundColor 设置为橙色以显示哪些项目已更改。 但
我正在尝试更改 OSX 应用程序的标题栏颜色。使用 window!.backgroundColor = .... 有时有效,但其他则无效。或者更具体地说,它有时在运行应用程序时起作用,而不是在其他应用
这是我的问题: var mycss = window.getComputedStyle(myelement); 返回一个 CSSStyleDeclaration 对象: CSSStyleDeclara
我是一名优秀的程序员,十分优秀!