Skip to content

Commit 4777e6b

Browse files
authored
Merge pull request #162 from Youssef1313/fix-binding-issue
Fix binding issue for Uno
2 parents b365dd2 + ac26faa commit 4777e6b

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/Codebreaker.Uno/CodebreakerUno/Views/Components/PegSelectionComponent.xaml.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@ public PegSelectionComponent()
1717
public GamePageViewModel ViewModel
1818
{
1919
get => (GamePageViewModel)GetValue(ViewModelProperty);
20-
set
21-
{
22-
SetValue(ViewModelProperty, value);
23-
DataContext = ViewModel;
24-
}
20+
set => SetValue(ViewModelProperty, value);
2521
}
2622

2723
public static readonly DependencyProperty ViewModelProperty =
28-
DependencyProperty.Register("ViewModel", typeof(GamePageViewModel), typeof(PegSelectionComponent), new PropertyMetadata(null));
24+
DependencyProperty.Register("ViewModel", typeof(GamePageViewModel), typeof(PegSelectionComponent), new PropertyMetadata(null, propertyChangedCallback: OnViewModelChanged));
25+
26+
private static void OnViewModelChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
27+
{
28+
var @this = (PegSelectionComponent)dependencyObject;
29+
@this.DataContext = (GamePageViewModel)args.NewValue;
30+
}
2931

3032
public void Receive(GameMoveMessage message)
3133
{

0 commit comments

Comments
 (0)