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.
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 application1>
<1 br="" layout...="" mb="" to="">
1>
<1 br="" layout...="" mb="" to="">
1> <1 br="" layout...="" mb="" to="">ClickMeEvent_161>
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).
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 application1>
<1 br="" layout...="" mb="" to="">
1>
<1 br="" layout...="" mb="" to="">
1> <1 br="" layout...="" mb="" to="">ClickMeEvent_161>
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
Posting Komentar