Binding in Textbox with Datagrid (WPF)

Asked

Viewed 299 times

1

I have a Textbox where you get the customer id and I also have a Datagrid where he has some personal information. Well so far so good, what I’m not getting is to connect the two in the following way:

When I change the value of the Textbox (client id) by changing focus, it would have to change the Datagrid data according to the client selected in the Textbox

<TextBox Text="{Binding ElementName=dataGridTelefones, 
                Path=SelectedItem.id_empresa,
                NotifyOnSourceUpdated=True}" 
         Name="textCodigo" />

<DataGrid AutoGenerateColumns="False" HorizontalAlignment="Left"
          Margin="12,12,0,0" VerticalAlignment="Top"
          ItemsSource="{Binding}" Name="dataGridTelefones" Height="100"
          Canvas.Left="113" Canvas.Top="539"
          Width="938" FontWeight="Normal" GridLinesVisibility="All"
          IsReadOnly="True" IsSynchronizedWithCurrentItem="True">
          <DataGrid.Columns>
              <DataGridTextColumn Binding="{Binding Path=prefixo}"
                                  Header="Prefixo" />
              <DataGridTextColumn Binding="{Binding Path=telefone}"
                                  Header="Telefone" />
              <DataGridTextColumn Binding="{Binding Path=obs}"
                                  Header="Observações" />
          </DataGrid.Columns>
</DataGrid>

Could someone help me?

No answers

Browser other questions tagged

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