One control - multiple properties

Asked

Viewed 62 times

0

I have a Combobox and it has as itemssource a struct with some properties, and I have a viewModel that has some properties of this struct, i wonder if there is a way to make the combobox set the viewmodel parameters equal to certain parameters of the selected item.

Of course, I could create one more property of my VM and it be of the type of that struct, then I would put the combobox selecteditem equal to this new property, unfortunately in this specific scenario I can’t do that.

<ComboBox ItemsSource="{Binding Source={StaticResource estados}, Path=Siglas}"
                      SelectedItem="{Binding Emit.endereco.SiglaUF, Mode=TwoWay}"
                      Header="Estado" />
            <ComboBox ItemsSource="{Binding Emit.endereco.SiglaUF, Converter={StaticResource obterMunicipios}}"
                      SelectedItem="{Binding Path=ConjuntoMunicipio, Mode=TwoWay}"
                      DisplayMemberPath="Nome"
                      Header="Município" />

    public Municipio ConjuntoMunicipio
    {
        get => Municipios.Get(Emit.endereco.SiglaUF).FirstOrDefault(x => x.Codigo == Emit.endereco.CodigoMunicipio);
        set
        {
            Emit.endereco.NomeMunicipio = value?.Nome;
            Emit.endereco.CodigoMunicipio = value?.Codigo ?? 0;
        }
    }
  • put what you already have as code that then the staff can help better

  • I don’t know how much help this is gonna be.

  • believe me! ;)

  • I’m believing and waiting kkk

  • @Andrepaul now has how to know what is Conjunctomunicipio.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.