我開發與Visual Studio應用Android
,我有文件ItemsPage.xaml
與此代碼:如何更改StackLayout中的顏色?
<ContentPage.Content>
<StackLayout>
<ListView x:Name="ItemsListView" ItemsSource="{Binding Items}" VerticalOptions="FillAndExpand" HasUnevenRows="true" RefreshCommand="{Binding LoadItemsCommand}" IsPullToRefreshEnabled="true" IsRefreshing="{Binding IsBusy, Mode=OneWay}" CachingStrategy="RecycleElement" ItemSelected="OnItemSelected">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout x:Name="General" Orientation="Horizontal" HorizontalOptions="Fill" Padding="5">
<Image Source="{Binding FileName, Converter={StaticResource ImageConverter}}" HeightRequest="150" WidthRequest="150" AbsoluteLayout.LayoutBounds="250.25, 0.25, 50, 50 "/>
<StackLayout Orientation="Vertical">
<Label Text="ST:" /><Label Text = "{Binding ST_string}" FontSize="24" AbsoluteLayout.LayoutBounds="0.25, 0.25, 400, 40"/>
<Label Text="Folio:" /><Label Text = "{Binding Folio_string}" FontSize="24" AbsoluteLayout.LayoutBounds="0.25, 0.25, 400, 40"/>
<Label Text="txt" /><Label Text = "{Binding Sent} " FontSize="24" AbsoluteLayout.LayoutBounds="0.25, 0.25, 400, 40"/>
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage.Content>
在我ItemsPage.xaml.cs
我無法訪問我的StackLayout
與Name="General"
,我需要色漆這一點,但我不能,請幫助。
一般我不能做General.Background,我不知道這個訪問。
謝謝!
但我需要修改BACKGROUNDCOLOR在某些情況下,你應該解釋一下我的解決方案爲:
然後添加
ContentView
到ViewCell
這似乎是我需要的。 – fabulias您可以通過查看以下簡短教程開始使用:https://xamarinhelp.com/xamarin-forms-user-control/實際上,「ContentView」就像是「ContentPage」,但您可以將「ContentView」 '在頁面內 –
我不明白兄弟,你能幫我嗎?請 – fabulias