In this step, you will add code to your UWP application to provide functionality to the added C1ColorPicker controls. Since you have already designed the user interface for your application in the previous step, complete the following steps to add functionality.
Visual Basic |
Copy Code
|
---|---|
Imports C1.Xaml Imports C1.Xaml.Extended |
C# |
Copy Code
|
---|---|
using C1.Xaml; using C1.Xaml.Extended; |
Visual Basic |
Copy Code
|
---|---|
Private Sub UpdateGradient() If C1ColorPicker1 IsNot Nothing And C1ColorPicker2 IsNot Nothing Then Me.col1.Color = Me.C1ColorPicker1.SelectedColor Me.col2.Color = Me.C1ColorPicker2.SelectedColor End If End Sub Private Sub C1ColorPicker1_SelectedColorChanged(sender As Object, e As PropertyChangedEventArgs(Of Windows.UI.Color))Handles C1ColorPicker1.SelectedColorChanged UpdateGradient() End Sub |
C# |
Copy Code
|
---|---|
void UpdateGradient() { if (C1ColorPicker1 != null & C1ColorPicker2 != null) { this.col1.Color = this.C1ColorPicker1.SelectedColor; this.col2.Color = this.C1ColorPicker2.SelectedColor; } } private void C1ColorPicker1_SelectedColorChanged(object sender, C1.Xaml.PropertyChangedEventArgs < Windows.UI.Color > e) { UpdateGradient(); } |
Visual Basic |
Copy Code
|
---|---|
Private Sub C1ColorPicker2_SelectedColorChanged(sender As Object, e As PropertyChangedEventArgs(Of Windows.UI.Color)) Handles C1ColorPicker2.SelectedColorChanged UpdateGradient() End Sub |
C# |
Copy Code
|
---|---|
private void C1ColorPicker2_SelectedColorChanged(object sender, PropertyChangedEventArgs < Windows.UI.Color > e) { UpdateGradient(); } |
With this, you have completed the addition of code to your UWP application and added functionality to the added ColorPicker controls. In the next step, you will run the application to see how the controls function at runtime.