I'm developing an application that contains a ListView. The items on the ListView should be either on the left or on the right of the screen depending on the item's content. So i created a converter to check the item and set a LinearLayout gravity. The converter is being called and it's returning right or left "correctly", but the LinearLayout is not being set. The Linear Layout is the following:
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="#FFFFFF"
local:MvxBind="Gravity Content, Converter=MessageAlign">
The converter I tried it in 2 different ways, one using GravityFlags and the other strings:
public class MessageAlignConverter : MvxValueConverter<string, GravityFlags>
{
protected override GravityFlags Convert(string value, Type targetType, object parameter, CultureInfo culture)
{
if (My Test)
{
return GravityFlags.Right;
}
return GravityFlags.Left;
}
}
public class MessageAlignConverter : MvxValueConverter<string, string>
{
protected override string Convert(string value, Type targetType, object parameter, CultureInfo culture)
{
if (My Test)
{
return "right";
}
return "left";
}
}
Neither one of them worked, so i checked the LinkerPleaseInclude. I tried adding in the LinkerPleaseInclude but i cannot get the current gravity, for a button (as example) i would do:
public void Include(Button button)
{
button.Click += (s,e) => button.Text = button.Text + "";
}
So i imagined something like this for the LinearLayout:
public void Include(LinearLayout linearLayout)
{
linearLayout.SetGravity(linearLayout.Gravity?);
}
Any ideas on how to do this?
Forgot to mention the output:
MvxBind:Warning: 6.00 Failed to create target binding for binding Gravity for Content
[0:] MvxBind:Warning: 6.00 Failed to create target binding for binding Gravity for Content
10-26 15:43:51.796 I/mono-stdout(11936): MvxBind:Warning: 6.00 Failed to create target binding for binding Gravity for Content
Thanks!