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

Copy attached properties to new instance in xamarin forms

$
0
0

I am creating new instance of grid object which have two labels as following.


<Grid.ColumnDefinitions>


</Grid.ColumnDefinitions>
<Grid.RowDefinitions>

</Grid.RowDefinitions>


I am using Activator.CreateInstance method as given below:

Grid ClonedView =(Grid) Activator.CreateInstance(Grid.GetType());

        foreach (PropertyInfo propertyInfo in Grid.GetType().GetProperties())
        {
            if (propertyInfo.CanRead && propertyInfo.CanWrite  )
            {

                object PropertyValue = propertyInfo.GetValue(Grid, null);

                propertyInfo.SetValue(ClonedView, PropertyValue);

            }
        }

When I use this ClonedView in my page, but Cloned Grid don't understand that Label2 should appear in second column of grid. I did a lot of research on it but could not find any solution. Please let me know if anybody has any solutions.

thanks


Viewing all articles
Browse latest Browse all 77050

Trending Articles



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