Hello,
I tried to use x:Name but it not working . and give me error say"Error CS0103 The name 'testborder' does not exist in the current context"`
Because elements will be re-used in Datatemple of Collectionview, you can not get elements by x:Name.
But you can use data-binding and mvvm to implement it.
I need to control this shadow on platform which I will use.
For example, I want to add the shadow for Image control like following code. I bind the two properties for Image Shadow called ShaodowColor and ShadowRadius
<CollectionView ItemsSource="{Binding Monkeys}">
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Padding="10">
<Image
Source="{Binding ImageUrl}"
Aspect="AspectFill"
HeightRequest="60"
WidthRequest="60" >
<Image.Shadow>
<Shadow Brush="{Binding ShaodowColor}"
Offset="20,20"
Radius="{Binding ShadowRadius}"
Opacity="0.8" />
</Image.Shadow>
</Image>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
Then you can add these property in your Model.
public class Monkey
{
public string ImageUrl { get; set; }
public string ShaodowColor { get; set; }
public int ShadowRadius { get; set; }
}
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.