어떻게 바인딩 오브젝트를 문자열로 변환 하시겠습니까? 나는 바인딩 속성을 사용하여 속성에 텍스트를 결합하기 위해 노력하고있어,하지만 난이 잡은 것Xamarin.Forms.Binding을 System.string으로 변환하십시오.
cannot convert from Xamarin.Forms.Binding to System.string.
내가 대해서 typeof (문자열)을 BindableProperty returnType이 가정라는 오류를 받고 있어요.
다음<local:MenuItem ItemTitle="Length" ItemImage="icons/blue/next" ItemSubText="{Binding App.rug.Length}" PageToo="{Binding lengthpage}"/>
내 백엔드 코드입니다 : 여기
public class MenuItem : ContentView
{
private string itemsubtext { get; set; }
public static BindableProperty SubTextProperty = BindableProperty.Create("ItemSubText", typeof(string), typeof(MenuItem), null, BindingMode.TwoWay);
public MenuItem()
{
var menuTapped = new TapGestureRecognizer();
menuTapped.Tapped += PushPage;
StackLayout Main = new StackLayout
{
Children = {
new SectionLine(),
new StackLayout {
Padding = new Thickness(10),
Orientation = StackOrientation.Horizontal,
HorizontalOptions = LayoutOptions.Fill,
Children = {
new Label {
Margin = new Thickness(10, 2, 10, 0),
FontSize = 14,
TextColor = Color.FromHex("#c1c1c1"),
HorizontalOptions = LayoutOptions.End,
Text = this.ItemSubText
}
}
}
}
};
Main.GestureRecognizers.Add(menuTapped);
Content = Main;
}
public string ItemSubText
{
get { return itemsubtext; }
set { itemsubtext = value; }
}
}
오류된다
다음 내 프런트 엔드 코드입니다 (App.rug.Length은 문자열입니다)Xamarin.Forms.Xaml.XamlParseException: Position 26:68. Cannot assign property "ItemSubText": type mismatch between "Xamarin.Forms.Binding" and "System.String"