I want to change the Image source in xamarin but I can't see the value I gave to x:name in .cs somehow? .xaml :
<Image Source="{local:ResourceResimExt ResourceId=OzelKalem.Content.images.yellowicon.png}" x:Name="resim_icon" VerticalOptions="CenterAndExpand" HorizontalOptions="Start" Margin="49,-28,0,0" IsVisible="true" WidthRequest="16" HeightRequest="16"/>
I want to write like this on xaml.cs:
resim_icon.Source = ImageSource.FromFile("redicon.png");
i tried it didn't work:
if ((KalanGun < 0 && durum == 1) && sonTarih < DateTime.Now)
{
ResourceResimExt resource = new ResourceResimExt();
resource.ResourceId = "OzelKalem.Content.images.redicon.png";
var imageSource = ImageSource.FromResource("OzelKalem.Content.images.redicon.png");
Xamarin.Forms.ImageSource.FromResource("OzelKalem.Content.images.redicon.png");
}
else if ((KalanGun > 0 && durum == 2) || durum == 2)
{
ResourceResimExt resource = new ResourceResimExt();
resource.ResourceId = "OzelKalem.Content.images.greenicon.png";
var imageSource = ImageSource.FromResource("OzelKalem.Content.images.greenicon.png");
Xamarin.Forms.ImageSource.FromResource("OzelKalem.Content.images.greenicon.png");
//resim.ResourceId = "OzelKalem.Content.images.greenicon.png";
}
and
xaml :<Image Source="{Binding ImageSource}"/>
xaml.cs:
private ImageSource _imageSource;
public ImageSource ImageSource
{
get { return _imageSource; }
set { _imageSource = value; }
}
if ((KalanGun < 0 && durum == 1) && sonTarih < DateTime.Now)
{
_imageSource = ImageSource.FromResource("OzelKalem.Content.images.redicon.png");
}
Actually there is something like embedded image structure in my project. But I couldn't understand how to change it dynamically in xaml.cs so I tried everything and it didn't work. Image source needs to be changed.
just below this code is used like this: