@@ -24,12 +24,12 @@ public partial class SelectionView : Grid
2424 public static GlobalSetting GlobalSetting { get ; private set ; } = new GlobalSetting
2525 {
2626 Color = InputKitOptions . GetAccentColor ( ) ,
27- BackgroundColor = ( Color ) VisualElement . BackgroundColorProperty . DefaultValue ,
27+ BackgroundColor = Colors . LightGray ,
2828 BorderColor = ( Color ) Button . BorderColorProperty . DefaultValue ,
2929 CornerRadius = 20 ,
3030 FontSize = Device . GetNamedSize ( NamedSize . Default , typeof ( Button ) ) ,
3131 Size = - 1 ,
32- TextColor = ( Color ) Button . TextColorProperty . DefaultValue ,
32+ TextColor = ( Color ) Label . TextColorProperty . DefaultValue ,
3333 LabelPosition = LabelPosition . After
3434 } ;
3535
@@ -209,6 +209,9 @@ private void UpdateView()
209209 if ( ItemsSource == null ) return ;
210210
211211 Children . Clear ( ) ;
212+
213+ SetRowAndColumnDefinitions ( ) ;
214+
212215 SetValue ( SelectedItemProperty , null ) ;
213216 foreach ( var item in ItemsSource )
214217 {
@@ -227,9 +230,10 @@ private void UpdateView()
227230 _View . IsDisabled = true ;
228231
229232 var addedView = _View as View ;
230- this . Add ( addedView ,
231- column : Children . Count % ColumnNumber ,
232- row : Children . Count % ColumnNumber ) ;
233+ var column = Children . Count % ColumnNumber ;
234+ var row = Children . Count / ColumnNumber ;
235+
236+ this . Add ( addedView , column , row ) ;
233237
234238 _View . IsSelected = Children . Count == _selectedIndex ; //to keep selected index when content is changed
235239 }
@@ -240,6 +244,21 @@ private void UpdateView()
240244 }
241245 }
242246
247+
248+ protected void SetRowAndColumnDefinitions ( )
249+ {
250+ this . ColumnDefinitions . Clear ( ) ;
251+ for ( int i = 0 ; i < ColumnNumber ; i ++ )
252+ {
253+ this . ColumnDefinitions . Add ( new ColumnDefinition ( GridLength . Star ) ) ;
254+ }
255+
256+ this . RowDefinitions . Clear ( ) ;
257+ for ( int i = 0 ; i < ItemsSource . Count / ColumnNumber ; i ++ )
258+ {
259+ this . RowDefinitions . Add ( new RowDefinition ( GridLength . Auto ) ) ;
260+ }
261+ }
243262 /// <summary>
244263 /// Updates colors of inside, when color property changed on runtime
245264 /// </summary>
@@ -426,7 +445,6 @@ public class SelectableButton : Button, ISelection
426445 private Color _selectionColor = InputKitOptions . GetAccentColor ( ) ;
427446 private Color _unselectedColor ;
428447
429-
430448 /// <summary>
431449 /// Default constructor
432450 /// </summary>
@@ -497,7 +515,7 @@ private void UpdateColors()
497515 else
498516 {
499517 BackgroundColor = UnselectedColor ;
500- TextColor = GlobalSetting . TextColor ;
518+ TextColor = GlobalSetting . TextColor ?? UnselectedColor ? . ToSurfaceColor ( ) ;
501519 }
502520 }
503521
0 commit comments