How can I disable image if I can do it?
For example, [Build your first app link](https://i.stack.imgur.com/yUV9l.png)
MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="AppMaui.MainPage">
<ScrollView>
<VerticalStackLayout
Padding="30,0"
Spacing="25">
<Image
Source="dotnet_bot.png"
HeightRequest="185"
Aspect="AspectFit"
SemanticProperties.Description="dot net bot in a race car number eight" />
<Label
Text="Hello, World!"
Style="{StaticResource Headline}"
SemanticProperties.HeadingLevel="Level1" />
<Label
Text="Welcome to .NET Multi-platform App UI"
Style="{StaticResource SubHeadline}"
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to dot net Multi platform App U I" />
<Button
x:Name="CounterBtn"
Text="Click me"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
IsEnabled="False"
HorizontalOptions="Fill" />
</VerticalStackLayout>
</ScrollView>
</ContentPage>
MainPage.xaml.cs
namespace AppMaui
{
public partial class MainPage : ContentPage
{
int count = 0;
public MainPage()
{
InitializeComponent();
}
private void OnCounterClicked(object sender, EventArgs e)
{
count++;
if (count == 1)
CounterBtn.Text = $"Clicked {count} time";
else
CounterBtn.Text = $"Clicked {count} times";
SemanticScreenReader.Announce(CounterBtn.Text);
}
}
}
I want to disable image for default and make it enabled after clicking button.
I change image, add button
<Button
x:Name="MakePictureButton"
Text="Make counter"
SemanticProperties.Hint="button make picture of counter"
Clicked="OnMakePictureClicked"
HorizontalOptions="Fill" />
and write OnMakePictureClicked
private void OnMakePictureClicked(object sender, EventArgs e)
{
if (count == 0)
{
CounterImage.IsEnabled = true;
CounterBtn.IsEnabled = true;
MakePictureButton.IsEnabled = false;
}
}
but I still can see image before and after clicking any button.
I’m beginer in maui/c#/xaml.
What I need to do?
Can I do this by other way?
>Solution :
If you want to make the image disappear you can do this.
CounterImage.IsVisible = false;