Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6779289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:22:04+00:00 2026-05-26T16:22:04+00:00

This is the code i using, but i not sure why it can be

  • 0

This is the code i using, but i not sure why it can be implement via the way i done in window form.

        Button[] btnMonday = new Button[20];
        string[] timeslot = { "08:00 AM", "08:30 AM", "09:00 AM", "09:30 AM", "10:00 AM", "10:30 AM", "11:00 AM", "11:30 AM", "12:00 PM", "12:30 PM", "01:00 PM", "01:30 PM", "02:00 PM", "02:30 PM", "03:00 PM", "03:30 PM", "04:00 PM", "04:30 PM", "05:00 PM", "05:30 PM" };

        #region Monday
        for (int i = 0; i < 20; i++)
        {
            btnMonday[i].SetValue(Height, 38);
            btnMonday[i].SetValue(Width, 256);
            btnMonday[i].SetValue(Content, timeslot[i]);
            btnMonday[i].SetValue(Background, 0xFF, 0xB1, 0xB1, 0xB1);

            // Sets dependency properties
            btnMonday[i].SetValue(Grid.ColumnProperty, 0);
            btnMonday[i].SetValue(Grid.RowProperty, i + 1);
            // Adds the dynamically created control to the canvas
            LayoutRoot.Children.Add(btnMonday[i]);
        }

update

i still getting error with this portion of code ::

 Button[] btnMonday = new Button[20];
            string[] timeslot = { "08:00 AM", "08:30 AM", "09:00 AM", "09:30 AM", "10:00 AM", "10:30 AM", "11:00 AM", "11:30 AM", "12:00 PM", "12:30 PM", "01:00 PM", "01:30 PM", "02:00 PM", "02:30 PM", "03:00 PM", "03:30 PM", "04:00 PM", "04:30 PM", "05:00 PM", "05:30 PM" };

            #region Monday
            for (int i = 0; i < 20; i++)
            {
                btnMonday[i] = new Button();
                btnMonday[i].SetValue(Height, 38);
                btnMonday[i].SetValue(Width, 256);
                btnMonday[i].SetValue(Content, timeslot[i]);

                // Sets dependency properties
                btnMonday[i].SetValue(Grid.ColumnProperty, 0);
                btnMonday[i].SetValue(Grid.RowProperty, i + 1);
                // Adds the dynamically created control to the canvas
                LayoutRoot.Children.Add(btnMonday[i]);
            }

is there any possibility of syntac error ?? and may i know how to set value of background to button ?? it seem not work well with the previous style of define background color.The error i get ::

Error   2   Argument 1: cannot convert from 'double' to 'System.Windows.DependencyProperty' 

and

Error   1   The best overloaded method match for 'System.Windows.DependencyObject.SetValue(System.Windows.DependencyProperty, object)' has some invalid arguments

for this few line

        btnMonday[i].SetValue(Height, 38);
        btnMonday[i].SetValue(Width, 256);
        btnMonday[i].SetValue(Content, timeslot[i]);
        btnMonday[i].SetValue(Background, 0xFF, 0xB1, 0xB1, 0xB1);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:22:05+00:00Added an answer on May 26, 2026 at 4:22 pm

    if you insist using SetValue method, try this:

            btnMonday[i].SetValue(Button.WidthProperty, 38);
            btnMonday[i].SetValue(Button.HeightProperty, 256);
            btnMonday[i].SetValue(Button.ContentProperty, timeslot[i]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am using this code <a onclick=javascript:var t=setInterval(GetUpdates(5,ajaxResult),300);>GetUpdates</a> but getting the syntax error
i've tried using this code and this to make a random quote generator, but
I'm using following code but cannot return data from MySQL. This is the output:
I am using pseudo-code here, but this is in JavaScript. With the most efficient
I am using the BlockingQueue code posted in this question , but realized I
This is the example code, I'm using these functions for a program, but scanf
I am trying to save drafts using NSUserDefaults but I am not sure if
Having this code: using (BinaryWriter writer = new BinaryWriter(File.Open(ProjectPath, FileMode.Create))) { //save something here
I have this code :- using (System.Security.Cryptography.SHA256 sha2 = new System.Security.Cryptography.SHA256Managed()) { .. }
I have this code: using DC = MV6DataContext; using MV6; // Business Logic Layer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.