I want to make a custom view as it is used a bunch of places.
In essence, it is just a comment label, and a stacklayout with labels containing tags regarding the comment.
[somewhat simplified]
<StackLayout>
<Label x:Name="commentLabel"/>
<!--The commentStackLayout should contain Labels with tags-->
<StackLayout x:Name="commentStackLayout" Orientation="Horizontal"/>
</StackLayout>
In my viewController, I have an observable collection of strings which I would like to databind to this component in such a fashion that the commentStackLayout will contain individual labels coresponding to each string in the collection.
Anyone know how to accomplish this?
What I have done:
I have databound the commentLabel in the normal fashion like this:
public static BindableProperty CommentProperty = BindableProperty.Create(
propertyName: "Comment",
returnType: typeof(string),
declaringType: typeof(MyComponent),
defaultValue: "",
defaultBindingMode: BindingMode.OneWay,
propertyChanged: HandleCommentChanged);
private static void HandleCommentChanged(BindableObject bindable, object oldValue, object newValue)
{
var detailHeader = (MyComponent)bindable;
detailHeader.commentLabel = newValue.ToString();
}
public string Comment
{
get { return (string)GetValue(CommentProperty); }
set { SetValue (CommentProperty, value); }
}
I am however unsure how to bind the collection.
Any help would be appriciated.