【发布时间】:2018-10-26 15:13:04
【问题描述】:
在其标题中设置 XAML 页面的 bindingContext 的正确语法是什么(定义命名空间和 x:class 的位置)?
我知道可以设置
<ContentView.ContextBinding>
<vm:RedViewModel/>
</ContentView.ContextBinding>
但是像下面这样的例子,看起来会更整洁
<?xml version="1.0" encoding="UTF-8" ?>
<ContentView x:Class="MVVMFramework.VVMs.Red.RedView"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:vm="clr-namespace:MVVMFramework.VVMs.Red"
BackgroundColor="Red"
BindingContext="{Binding Source = {vm:RedViewModel}}"> //Something like this
【问题讨论】:
标签: xaml xamarin data-binding xamarin.forms