Browse Source

DataGrid: update samples page

Maksym Katsydan 5 years ago
parent
commit
8819b2481e

+ 4 - 4
samples/ControlCatalog/Models/GDPValueConverter.cs

@@ -19,11 +19,11 @@ namespace ControlCatalog.Models
             if (value is int gdp)
             {
                 if (gdp <= 5000)
-                    return Brushes.Orange;
+                    return new SolidColorBrush(Colors.Orange, 0.6);
                 else if (gdp <= 10000)
-                    return Brushes.Yellow;
+                    return new SolidColorBrush(Colors.Yellow, 0.6);
                 else
-                    return Brushes.LightGreen;
+                    return new SolidColorBrush(Colors.LightGreen, 0.6);
             }
 
             return value;
@@ -34,4 +34,4 @@ namespace ControlCatalog.Models
             throw new NotImplementedException();
         }
     }
-}
+}

+ 12 - 0
samples/ControlCatalog/Models/Person.cs

@@ -15,6 +15,7 @@ namespace ControlCatalog.Models
     {
         string _firstName;
         string _lastName;
+        bool _isBanned;
 
         public string FirstName
         {
@@ -47,6 +48,17 @@ namespace ControlCatalog.Models
             }
         }
 
+        public bool IsBanned
+        {
+            get => _isBanned;
+            set
+            {
+                _isBanned = value;
+
+                OnPropertyChanged(nameof(_isBanned));
+            }
+        }
+
         Dictionary<string, List<string>> _errorLookup = new Dictionary<string, List<string>>();
 
         void SetError(string propertyName, string error)

+ 2 - 1
samples/ControlCatalog/Pages/DataGridPage.xaml

@@ -44,7 +44,8 @@
           <DataGrid Name="dataGridEdit" Margin="12" Grid.Row="0">
             <DataGrid.Columns>
               <DataGridTextColumn Header="First Name" Binding="{Binding FirstName}" Width="2*" />
-              <DataGridTextColumn Header="Last" Binding="{Binding LastName}" Width="*" />
+              <DataGridTextColumn Header="Last" Binding="{Binding LastName}" Width="2*" />
+              <DataGridCheckBoxColumn Header="Is Banned" Binding="{Binding IsBanned}" Width="*" />
             </DataGrid.Columns>
           </DataGrid>
           <Button Grid.Row="1" Name="btnAdd" Margin="12,0,12,12" Content="Add" HorizontalAlignment="Right" />

+ 1 - 1
samples/ControlCatalog/Pages/DataGridPage.xaml.cs

@@ -33,7 +33,7 @@ namespace ControlCatalog.Pages
             var items = new List<Person>
             {
                 new Person { FirstName = "John", LastName = "Doe" },
-                new Person { FirstName = "Elizabeth", LastName = "Thomas" },
+                new Person { FirstName = "Elizabeth", LastName = "Thomas", IsBanned = true },
                 new Person { FirstName = "Zack", LastName = "Ward" }
             };
             var collectionView3 = new DataGridCollectionView(items);