Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF ListBox: how to update data with binding
    text
    copied!<p>I have listbox that displays information about list of objects:</p> <pre><code> &lt;ListBox Grid.Column="0" Height="152" Name="CustomersList" HorizontalAlignment="Stretch"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;TextBlock Text="{Binding Path=Name, Mode=OneWay}"/&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; </code></pre> <p>I would show more detailed information about selected item in another block, but I don't know (and can't find) how to bind selected item to those block data context. I guess it should be something like this:</p> <pre><code> &lt;Grid Grid.Column="1" DataContext="{Binding Path=ItemSelected, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="150"/&gt; &lt;ColumnDefinition Width="250"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition /&gt; &lt;RowDefinition/&gt; &lt;RowDefinition/&gt; &lt;/Grid.RowDefinitions&gt; &lt;TextBlock Grid.Row="0" Grid.Column="0" Text="Id" VerticalAlignment="Center" /&gt; &lt;TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path=Id}" VerticalAlignment="Center"/&gt; &lt;TextBlock Grid.Row="1" Grid.Column="0" Text="Name" VerticalAlignment="Center"/&gt; &lt;TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Path=Name}" VerticalAlignment="Center"/&gt; &lt;StackPanel Grid.Row="2" Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Center"&gt; &lt;Button Content="Add new" /&gt; &lt;Button Content="Store changes" /&gt; &lt;/StackPanel&gt; &lt;/Grid&gt; </code></pre> <p>But the problem is that data item to be binded to the grid is not specified anywhere and I don't know how to do that.</p> <p>Any suggestion would be wellcome.</p> <p>Thanks!</p> <p>P.S. I've tried to specify CustomersList.ItemsSource as DataContext for the Grid - this didn't give any result.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload