Langsung ke konten utama

How Produce Yous Alter The Background Color Of A Xaml Push Using A Click Effect Inwards C#?

Sometimes yous ask to alter the background color from its default to a dissimilar color. Let us say, nosotros convey a push whose Background color needs changing past times an trial such equally the CLICK event.

How is it done?
Well, I could plow over yous a trouble of code to produce that. Perhaps it volition live on in addition to all that in that place is to it. However, if yous are beginner in addition to wondering how the hell it is coded alongside then much of background code, namespaces; classes, methods, events etc.

This postal service tries to demonstrate how yous may respect yourselves how to produce it.

If yous are looking for the 1 trouble of code, delight become to the halt in addition to yous volition respect it there. If yous are firstly to code in addition to novel to Microsoft; novel to Visual Studio inwards particular, follow on.

As mentioned inwards my previous postal service Universal Windows Project role XAML for the UI in addition to the pages.
Some of the things yous should retrieve is that yous should role intellisense equally much equally possible. You should also role code hints yous larn when your code is non doing what yous except.

In gild to illustrate permit us start alongside the code for a BUTTON click trial for a push named ClickMe as shown:
=========
public sealed partial shape MainPage : Page
    {
        populace MainPage()
        {
            this.InitializeComponent();
        }

    
        soul void ClickMe_Click(object sender, RoutedEventArgs e)
        {
            ClickMe.FontSize = 50;
           
        }
    }
}

===============

The inwards a higher house code changes the font-size to fifty when the push is clicked. We add together 1 to a greater extent than trouble which changes the BACKGROUND color to red.

Start alongside ClickMe (the object) past times typing below ClickMe inwards the inwards a higher house code.

As before long equally yous typein Click yous volition come across this:


ClickMeEvent_0

Pick ClickMe from the inwards a higher house in addition to add together a menstruum to it afterward that in addition to yous volition larn to a greater extent than pop-up equally shown.


ClickMeEvent_1

Pick Background in addition to your code looks similar this:


ClickMeEvent_3

You seek the 'dot trick' over again past times typing a point afterward Background equally shown. You produce larn a pop-up which does non seem to convey anything to produce alongside color.


ClickMeEvent_4

Now yous ask to know that color is given past times using a brush in addition to yous convey an Object called SolidColorBrush also other kinds. In XAML scenarios, Color is non referenced straight merely past times the element SolidColorBrush.


ClickMeEvent_5

Now yous type inwards SolidColorBrush merely yous larn the ruby-red wiggly (oops, something non right).


ClickMeEvent_6

You house your cursor on SolidColorBrush in addition to yous larn a hint. SolidColorBrush is a shape shout in addition to yous are looking for a color value. Instead of using the class, yous should role an instant of the shape alongside the 'new' keyword equally shown.


ClickMeEvent_7

The ruby-red wiggly is yet in that place merely yous convey made progress.

Well this gives a hint that yous must follow upwards this alongside 1 of [], {},or ().

Let us type the parenthesis-begin equally shown


ClickMeEvent_8

There are 2 options equally shown.


ClickMeEvent_9

The firstly method gives no color in addition to the instant options uses 1 of the Windows colors.


ClickMeEvent_10.jpg

Now I role the hint from the icon 1 previous to the above. And nosotros expire along alongside code equally shown.


ClickMeEvent_11.jpg

Well, over again nosotros are getting the shape COLOR. Place the cursor on the color in addition to respect out what is needed.

Now alongside the point fox nosotros are ahead to select a color nosotros want.


ClickMeEvent_12.jpg

Now nosotros convey to select the color from inserting proper values for the arguments of the business office
FromArgb() equally described inwards this postal service here.

Let us select a ALPHA (transparency)channel value of 255 in addition to a RED channel value of 255, BLUE channel value 0 in addition to Green channel vlaue of 0 equally shown. Type these into FromArgb() equally shown.


ClickMeEvent_14.jpg

Now nosotros are rid of the pesky ruby-red wiggly line. Ready to stone in addition to roll.

Build the code from the principal carte in addition to deploy it to the local automobile equally described inwards my before post.

The Build succeeds equally shown.


ClickMeEvent_15.jpg

Now Deploy the solution in addition to yous larn this resultant equally in that place are no errors:
========
Deploy started: Project: HelloWorld, Configuration: Debug x86 ------
Updating the layout...
Copying files: Total <1 br="" layout...="" mb="" to="">1>Checking whether required frameworks are installed...
Registering the application to run from layout...
Deployment consummate (0:00:18.287). Full packet name: "b940c521-2fb5-429c-9486-69bb2a425e90_1.0.0.0_x86__ckpvgz13cfhxc"

========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========
Now run the projection in addition to yous larn this display of  your application
<1 br="" layout...="" mb="" to="">

<1 br="" layout...="" mb="" to="">
<1 br="" layout...="" mb="" to="">ClickMeEvent_16

Now click the Hello push to come across the Background color in addition to font size alter equally shown.


ClickMeEvent_17

After verifying closed the application in addition to yous larn the next response:
==================
The plan '[15840] HelloWorld.exe' has exited alongside code 1 (0x1).

That's it folks!





Komentar

Postingan populer dari blog ini

What Happenned To My Restore Points Inward Windows 10?

They disappeared because in that place was an automatic update of the operating system. One creates organisation restore points to become dorsum inward representative in that place is a problem. Typically when you lot run into around rpoblem you lot would desire to become dorsum to a restore indicate you lot accept created. The restore indicate would notwithstanding last available to you lot were it non for the automatic Windows Updates. It would last squeamish if in that place is a agency of having OS on ane drive that does non update (so restore points are available) as well as OS on the other that tin update as well as install the better(?) code.

Download As Well As Install Written Report Builder For Sql Server 2016

Report Builder is a highly productive, stand-alone tool for authoring reports as well as deploying them on configured Microsoft Reporting services study servers. It tin purpose information from dissimilar kinds of information sources to produce  a multifariousness of reports, from difficult copies to spider web based reporting. Report Builder three Details: -------------- Version: 14.0.344.82 File Name: ReportBuilder3.msi Date Published: 3/9/2017 File Size: 22.6 MB ----------------- You require Microsoft .NET Framework 4.5 . The retentiveness as well as CPU requirements are average. This is supported on  the next OSs: Windows 10 , Windows 7, Windows 8, Windows 8.1, Windows Server 2008 R2, Windows Server 2008 R2 SP1, Windows Server 2012, Windows Server 2012 R2 download from here: https://www.microsoft.com/en-us/download/confirmation.aspx?id=53613 Please review the before versions of Report builder inwards 2 of my published books here: The minute ma...

What Is Wmi?

Windows Management Instrumentation(WMI) allows yous to work API calls to command systems together with services on Microsoft Windows 10 (also from Windows XP) through models Win32_LogicalDisk together with Win32_Process. You tin dismiss work WMI to command local together with remote machines. WMI is available for all Windows' versions. Some of the tasks that yous tin dismiss undertake amongst WMI are, Start a procedure on a remote computer. Schedule a procedure to run at specific times on specific days. Reboot a calculator remotely. Get a listing of applications installed on a local or remote computer. Query the Windows number logs on a local or remote calculator or multiple computers amongst a unmarried command. You access  WMI locally together with remotely using the interactive command WMIC inwards command-line every bit follows: ---------- C:\>wmic wmic:root\cli> ----------- Now yous tin dismiss encounter what WMI is close using the attention flag /? every bit follo...