我正在尝试在Xamarin.Forms项目中实现MVVM。
这是我的StackLayout
,带有x:Name
<StackLayout x:Name="approvalsStack"></StackLayout>
这就是我在此Children
StackLayout
的方式
StackLayout stack = new StackLayout();
Frame frame = new Frame { BorderColor = Color.LightGray };
frame.Content = new Label { Text = a.FullName + " (" + a.Decision + ")" + " " + a.DecisionDate.ToString() };
stack.Children.Add(frame);
approvalsStack.Children.Add(stack);
现在我被困住了,如何使用ViewModel / Binding来填充子代。
答案 0 :(得分:2)
您无法以这种方式进行操作,因为您可以看到here,@foreach($user->clients as $client )
{{$client->id}}
{{$client->title}}
<br>
@endforeach
中的属性let obj = {'r' : ['ca','ba','es']}
const r = obj.r[0];
const r2 = obj.r[1];
const r3 = obj.r[2];
const url = window.location.href + '?r=' + r + '&r=' + r2 + '&r=' + r3;
window.history.pushState({}, "", url);
不是Bindable property。
但是,您可以解决这一问题,方法是通过实现可绑定属性来定制一个,其中将包含一些Children
用于从中动态添加/删除项目,或者您也可以使用一些Xamarin.Forms的StackLayout
的社区实现,我建议您这样做。
ItemSource
基本上是可绑定的RepeaterView
,您可以在其中动态填充项目。
我建议您看看 here 中的这本Glenn Versweyveld,如果您想在Google或github上搜索更多其他内容, >(但我强烈建议您这样做)。
祝您编程愉快!
答案 1 :(得分:1)
找到了解决方案!
1-使用了RepeaterView的此实现 2-将名称空间添加到Xaml
2018-07-18 13:14:08 ::1 GET /Meetings - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/67.0.3396.99+Safari/537.36 - 404 0 0 1422
2018-07-18 13:22:54 ::1 GET / - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/67.0.3396.99+Safari/537.36 - 200 0 0 1841
并绑定转发器视图,然后使用ViewModel填充该视图