是否将Silverlight控件绑定到视图模型元素?

是否将Silverlight控件绑定到视图模型元素?,silverlight,windows-phone-7,wvvm,Silverlight,Windows Phone 7,Wvvm,假设我有: <TextBlock Text="{Binding MyString}"/> public class AlanViewModel { public string MyString {get; set;} public TextBlock Control { get; set; } //How to bind this to the TextBlock control? } 公共类模型{ 公共字符串MyString{get;set;} 公共TextBlock

假设我有:

<TextBlock Text="{Binding MyString}"/>

public class AlanViewModel {
  public string MyString {get; set;}
  public TextBlock Control { get; set; } //How to bind this to the TextBlock control?
}

公共类模型{
公共字符串MyString{get;set;}
公共TextBlock控件{get;set;}//如何将其绑定到TextBlock控件?
}
我可以将控件的实例绑定到ViewModel吗,还是必须继续跳过代码中的环以将它们耦合在一起

我知道这会将ViewModel与视图进行耦合,但这是有充分理由的。


<ContentControl Content="{Binding TextBlock}" />

对不起,我想知道我是否可以绑定TextBlock哦,天哪,我想我没有仔细考虑这个问题,我现在编辑了我的答案,请看它现在是否有帮助?!我可以确认它是有效的,我现在刚刚在一个测试应用程序中进行了测试。我认为ViewModels不应该包含UI控件!在这种情况下,值转换器可能会有所帮助。问题是UI控件提供了视图模型所需的功能。特别是将视口点转换为地理位置坐标。如果我能在绑定中做到这一点,我会这样做,但我看不到一种方法。也许你可以解释这个特定的问题(使用代码片段),我认为应该有一个使用绑定的解决方法;)非常负荷的警铃现在应该响了。“我必须继续跳转吗?”你认为通过在你的虚拟机中公开一个
TextBlock
属性,你还没有在跳转吗??这里是我高度推测的猜测,您已经在MVVM的祭坛上牺牲了简单性。我怀疑视图可以很容易地将视口点转换为地理位置,但这会违反规则,对吗?继续有点不听话,把它做完。