Code was working before but not working now.

BEKIR GULDIBI 0 Reputation points
2024-01-23T16:11:56.6366667+00:00
namespace NotHesaplamasi;

public partial class NotGirisSayfasi : ContentPage
{
    public NotGirisSayfasi()
    {
        InitializeComponent();
    }
    private void BtnCalculateBMI_Clicked(object sender, EventArgs e)
    {
        double vize = double.Parse(LblVize.Text);
        double final = double.Parse(LblFinal.Text);
        double BasariNot = (vize * 0.4 + final * 0.6);
        Navigation.PushAsync(new NotSonucSayfasi(BasariNot));

    }
    private void Slider_ValueChanged(object sender, EventArgs e)
    {
        double viz = SliderVize.Value;
        double fin = SliderFinal.Value;
        double BasariNotu = (viz * 0.4 + fin * 0.6);
      
        if (BasariNotu >= 50)
        {
            //LblBasari.TextColor = Color.Parse("Green");
            LblBasari.Text =BasariNotu.ToString()+" BAŞARILI ";
            ImageSonuc.Source = "neseli.jpeg";
           
        }
        else
        {
           //LblBasari.TextColor = Color.Parse("Red");
            LblBasari.Text = $"{BasariNotu:F1}" + " BAŞARISIZ ";
            ImageSonuc.Source = "uzgun.jpeg";
        }
    }
}

in this code , if I do not click the button. 
LblBasari.Text = $"{BasariNotu:F1}" + " BAŞARISIZ ";
this code does not work
Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
12,062 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 56,946 Reputation points
    2024-01-23T18:27:14.7766667+00:00

    Please provide us more information. What do you mean "it doesn't work"? The code doesn't execute? It executes but doesn't display the right values? etc.

    What does clicking the button have to do with any of this? They don't appear to be sharing any datapoints so most likely there is something that you're not showing us that is causing the problems.

    Have you tried debugging this by putting a breakpoint inside your Slider_ValueChanged method and then verifying it is being called. If it isn't then either the condition needed to trigger a value change isn't happening or you didn't properly register the event handler. If it is being called then step through the code line by line until it behaves the way you didn't expect. That is where the problem lies so you'll have to figure out what has to change to have the code behave the way you want. We don't have insight into your business logic for this.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.