1
我在.xmal文件中使用了一個標籤。以.xmal格式在.xmal和.cs之間進行數據訪問
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ListDemo.TableView">
<StackLayout>
<Label Text="Above TableView"></Label>
<TableView>
<TableView.Root>
<TableSection Title="Test">
<EntryCell Label="EntryCell"></EntryCell>
<TextCell Text="Test" Detail="Text Detail"></TextCell>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Horizontal" >
<BoxView Color="Red"></BoxView>
<StackLayout>
<Label Text="{Binding Receivename}"></Label>
<Label Text="News URL 1"></Label>
</StackLayout>
<BoxView x:Name="boxView" Color="Blue" ></BoxView>
</StackLayout>
</ViewCell.View>
</ViewCell>
</TableSection>
</TableView.Root>
</TableView>
</StackLayout>
我想設置從cs文件的標籤數據。
namespace ListDemo
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class TableView : ContentPage
{
public TableView()
{
InitializeComponent();
public string Receivename = "Hello";
}
}
}
請讓我知道,我怎麼可以設置標籤的動態數據。在.cs文件中寫什麼?
在此先感謝。
我是很新的xamarin。你能爲我編碼嗎?我很困惑,在哪裏寫和寫什麼在這裏設置數據 – Myaaoonn
謝謝..但它沒有顯示我「你好」在設備中。 :(我錯過了什麼.. – Myaaoonn
這個堆棧面板和標籤是否存在於'TableView的XAML中?也許會發布更多的XAMLs內容 – Toskr