Skip to content

Instantly share code, notes, and snippets.

@philcleveland
Created May 16, 2014 16:18
Show Gist options
  • Save philcleveland/88e7fab5b5a63ad0ed83 to your computer and use it in GitHub Desktop.
Save philcleveland/88e7fab5b5a63ad0ed83 to your computer and use it in GitHub Desktop.
RxUI combobox hack binding
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