The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 6 of 6

Thread: Mini Blend Calculator

  1. #1

    Mini Blend Calculator

    Well, Im trying to create a four function calculator with blend, but its kinda hard without a reference, so ill ask here.

    This is how it looks like.

    The little box at the right end is a label that displays the number.

    So im trying to use one event, which comes from the "calculate" button. Here is the event code just for the addition.
    Code:
            private void click(object sender, System.Windows.RoutedEventArgs e)
            {
                if (RadioButton.Content == "Addition")
                {
                    DiaplayNumber.Content = double.Parse(FirstNumber.Text) + double.Parse(SecondNumber.Text);                
                }
            }
    Thats my crack at it.. it obviously doesn't work. Any help?
    Attached Files Attached Files

  2. #2
    What error message are you receiving?

  3. #3
    An object reference is required for the nonstatic field, method, or property 'System.Windows.Controls.ContentControl.Content.ge t'
    Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string.'
    .

  4. #4
    The main issue is that you can't go RadioButton.Content, for RadioButton isn't really something you can use to check equality with a string with. That is what the error is essentially saying.

    Your radio buttons are called Add, Subtract, Multiply, and Divide, and those are the names you use to check whether one of them is selected. The code below should work:
    Code:
                if (Add.IsChecked == true)
                {
                    DisplayNumber.Content = double.Parse(FirstNumber.Text) + double.Parse(SecondNumber.Text);                
                }
    Second, are you using Visual C# 2008 Express? I received a prompt to upgrade your project to work in my copy of VC# Express 2008.

    Cheers!
    Kirupa

    Great, now even Kirupa is { facebooking | twittering }

  5. #5
    Thanks that worked. I tried "if(Add.Checked == true)" but that didn't work. And yes i am using Visual C# 2008. I deleted my '05 only few days ago. Maybe i need to upgrade Blend? I haven't downloaded the service pack 1.

  6. #6
    Oh, use Blend 2 December Preview - that is designed to work well with VS2008 solutions (or you can also download SP1 for Blend 1)

    Blend 2 Preview can be gotten from here: http://www.microsoft.com/downloads/d...displaylang=en

    Great, now even Kirupa is { facebooking | twittering }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012