zeed94
zeed94

Reputation: 131

Binding ComboBox in UWP used MvvmCross

Someone know, how to binding click on item (from ComobBox) with properties/method ? I try ICommand, but ComobBox doesn't have this.

Upvotes: 1

Views: 232

Answers (1)

zeed94
zeed94

Reputation: 131

Ok. I solved in such a way that binding SelectedIndex with the properties in View Model.

ViewModel source:

private int _id = -1;

    public int SelectedId
    {
        get
        {
            return _id;
        }
        set
        {
            _id = value;
            if (_id >= 0) { _device = Devices[_id]; Debug.WriteLine(Devices[_id].DeviceName); }
            RaiseAllPropertiesChanged();
        }
    }

View:

<ComboBox 
            HorizontalAlignment="Stretch" 
            VerticalAlignment="Stretch"
            Margin="0,0,0,10"
            ItemsSource="{Binding Devices}"
            ItemTemplate="{StaticResource ListItemTemplate}"
            SelectedIndex="{Binding SelectedId, Mode=TwoWay}">

Upvotes: 1

Related Questions