Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Access properties of nested view in xaml

$
0
0

Hello together,

I'm searching for a xaml way to access the properties of a view in a view. Currently I'm trying to create a UserControl which consists of an AbsoluteLayout which should contain a ListView.

Basically I wan't the UserControl to expose all ListView properties, so that I simply can set UserControl.ListView.BackgroundColor="Red".
(I known I could create the BackgroundColor als BindableProperty in the UserControl , but I don't want to create for every ListView property a new BindableProperty in the UserControl)

 <AbsoluteLayout xmlns="http://xamarin.com/schemas/2014/forms"
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
              x:Class="TestControl">


  <ListView HeightRequest="190" x:Name="MyListView" />

 </AbsoluteLayout>


 <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
              xmlns:components="clr-namespace:Components;assembly=Test"
              x:Class="TestPage">


   <components:TestControl x:Name="MyTestControl">    
        <!-- TODO: Access MyListView.BackgroundColor="Red" here -->
   </components:TestControl>

 </ContentPage>

In the code behind I could simply do
this.MyTestControl.MyListView.BackgroundColor= Color.Red;

Any ideas on this?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>