Click here to Skip to main content
15,885,164 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello there,
How can I pass values from IF-statement xaml.cs to cs. in WPF Application?
C#
private void Button_Click(object sender, RoutedEventArgs e)
        {
            if ( plus.IsChecked.Value == true && low.IsChecked.Value == true)
            {
                game lvl = new game();
                
                lvl.Show();
                this.Close();
            }

After clicking I would like them to verify all the agreed options and then the value would be sent to class1.
But I don´t know, how I pass the value from IF-statement. I tried it through enum but I'm lost too. Xaml.cs is the main application window In class1 I would just like to take a value so I can then use it in another xaml.cs with name game.cs.

What I have tried:

This is xaml.cs
C#
public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            game lvl = new game();
                
                lvl.Show();
                this.Close();
            }
            if ( plus.IsChecked.Value == true &&  high.IsChecked.Value == true)
            {
                game lvl = new game();
                
                lvl.Show();
                this.Close();
            }
...


this is cs.:
C#
class Vlastnosti
    {
        public enum Operation
        {
            pluslow, 
            plushigh,
                      

        }
        public static class Class1
        {
           

            static Class1()
            {
                
            }

        }
    }
}


Thank you for advice.
Posted
Updated 26-Apr-21 0:21am
v2
Comments
Richard Deeming 26-Apr-21 6:16am    
We can't help you, since you haven't told us what the connection is between Class1 and your code-behind, nor how you expect to use the value in Class1.
Member 15170612 26-Apr-21 6:22am    
I improved my question, is it better?
Richard Deeming 26-Apr-21 6:26am    
No. There's still no indication of a connection between the class and the code-behind, nor how you want to use the value in the class.
Richard Deeming 26-Apr-21 6:31am    
Which you haven't explained.

Remember, we can't see your screen, we can't access your computer, and we can't read your mind. All we have to work with is what you type in your question.

You've told us you want to "take a value" in Class1, but you've not explained what you mean by that.
Member 15170612 26-Apr-21 6:36am    
I will try it like this: after finding out which field is checked I would like the value that describes which field is checked pass to the class where it would be stored so that it can be used in the next xaml.cs

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900