2017-01-16 18 views
1

私が代わりにViewCellは、C#で定義されたカスタムを使用するには、以下のXAMLを変換したい...Xamarinフォーム - XAMLバインディングのC#の同等

​​

だから、変換した後、私はしている...

<ListView x:Name="___listview" HasUnevenRows="True"> 
    <ListView.ItemTemplate> 
    </ListView.ItemTemplate> 
</ListView> 

とC#...]ボタンのImageに必要な完全な結合構文にコードをある何

public partial class MainPage : ContentPage 
{ 
    public MainPage() 
    { 
     InitializeComponent(); 
     ___listview.ItemsSource = Repository.GetList(); 
     ___listview.ItemTemplate = new DataTemplate(typeof(CustomViewCell)); 
    } 
} 

public class CustomViewCell : ViewCell 
{ 
    bool _initialized = false; 

    public CustomViewCell() 
    { 
     var stack = new StackLayout(); 

     var button = new Button(); 

     stack.Children.Add(button); 

     View = stack; 
    } 
} 

nd CommandはXAMLで行われていますか?

答えて

4
var button = new Button(); 
button.SetBinding(Button.ImageProperty, new Binding("ImageName")); 
button.SetBinding(Button.CommandProperty, new Binding("ShowDetailsCommand")); 
関連する問題