Jump to content
Fórum Script Brasil
  • 0

COMBOBOX COM ITEMSOURCE DE OUTRA TABELA


crisaf
 Share

Question

Amigos, bom dia.

No banco de dados tenho 2 tabelas: types e cost_centers.

Os campos da tabela cost_centers são: cod, name e type(chave estrangeira para a tabela types[category]).

Os campos da tabela type são: category.

O datagrid está exibindo as informações da tabela cost_centers e uma de suas colunas é um combobox.

Esse combobox deve carregar todos os valores da tabela types, mas o selecteditem deve ser o valor da tabela cost_centers, coluna type.

Já tentei usar assim:

<ComboBox ItemsSource="{Binding DataContext.Types, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"
DisplayMemberPath="category"
SelectedItem="{Binding type}"
SelectedValue="{Binding Types.cod}"
SelectedValuePath="{Binding cod}"/>

Ele carrega os itens no combobox mas não seleciona o item correspondente ao registro.

Alguém pode me dizer como fazer isso?

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Forum Statistics

    • Total Topics
      149.6k
    • Total Posts
      646.2k
×
×
  • Create New...