2017-10-12 127 views

回答

1

你可以做這樣的事情

StackLayout stack = new StackLayout(); 

// controls is an collection of control definitions built from your json 
foreach(var c in controls) 
{ 
    if (c.Type == "Button") { 
    Button button = new Button(); 
    button.Text = c.Text; 
    stack.Add(button); 
    } 

    if (c.Type == "Label") { 
    Label label = new Label(); 
    label.Text = c.Text; 
    stack.Add(label); 
    } 

    // repeat for each supported type of control 
} 
+0

謝謝傑森的幫助。 – user2797877

+0

我有第二個Rest API,它具有我需要填入上述動態控件的數據,我如何實現該功能 – user2797877

+0

在開始之前合併列表。或者做第二遍添加數據。或者使用數據綁定。有多種方法可以處理它,但不知道更多細節,很難說哪種方法最適合。 – Jason

相關問題