Created
May 16, 2014 16:18
-
-
Save philcleveland/88e7fab5b5a63ad0ed83 to your computer and use it in GitHub Desktop.
RxUI combobox hack binding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
XAML | |
--------------------------------------------------------------- | |
<ComboBox Grid.Row="0" x:Name="gardens" Margin="10" FontSize="24"> | |
<ComboBoxItem>New...</ComboBoxItem> | |
<ComboBoxItem>G1</ComboBoxItem> | |
<ComboBoxItem>G2</ComboBoxItem> | |
<ComboBoxItem>G3</ComboBoxItem> | |
</ComboBox> | |
Code Behind | |
---------------------------------------------------------------- | |
this.WhenAny(x => x.gardens.SelectedItem, x => x.Value) | |
.Select(x => x == null ? string.Empty : x.ToString()) | |
.BindTo(this, x => x.ViewModel.SelectedGarden); | |
ViewModel code | |
---------------------------------------------------------------- | |
private string _SelectedGarden; | |
public string SelectedGarden | |
{ | |
get { return _SelectedGarden; } | |
set { this.RaiseAndSetIfChanged(ref _SelectedGarden, value); } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment