Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate source in datagrid via selection from combo box
    primarykey
    data
    text
    <p>I am new to WPF and the MVVM design pattern. Consequently, everything I try to do seems to take a long time. </p> <p>Currently I am using a combobox to select a list. I want to populate a gridview with all the contacts that are in that list and to refresh that gridview every time the combobox selection changes. </p> <p>The XAML for the view follows. How can I get the gridview to listen for a change in the combobox selection? I need the combobox selection to set it's property so that I can query the db to return those records associated with the list so my first thought was to add a button to fire the command but it never fires. I have read on google where it says the gridview should listen for the propertyupdated but no sample on just how to do that.</p> <p>I tried this in the gridview but throws an exception and yes my viewmodel does implement INotifyProperyChanged</p> <p>PropertyChanged="{Binding Path=SelectedListNameContactView}</p> <p>Your help is appreciated. </p> <pre><code> &lt;UserControl x:Name="manageLists" x:Class="Five9ContactManagement.ManageListsView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:my="clr-namespace:Five9ContactManagement.Controls;assembly=Five9ContactManagement.Controls" mc:Ignorable="d" d:DesignHeight="400" d:DesignWidth="400" xmlns:local="clr-namespace:Five9ContactManagement" &gt; &lt;Grid &gt; &lt;Grid HorizontalAlignment="Center" VerticalAlignment="Top" Margin="20"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition /&gt; &lt;ColumnDefinition /&gt; &lt;ColumnDefinition /&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.Column="0" Grid.Row="2" Text="Select List " VerticalAlignment="Center" Margin="5" /&gt; &lt;ComboBox Grid.Column="1" Grid.Row="2" ItemsSource="{Binding GetLists, Mode=OneWay}" VerticalAlignment="Center" SelectedIndex="-1" SelectedItem="{Binding Path=SelectedListNameContactView /&gt; &lt;Button Grid.Row="2" Grid.Column="2" Content="View Contacts" VerticalAlignment="Center" Margin="5" Width="100" Command="{Binding Path=ShowContactsCommand}" CommandParameter="{Binding SelectedListNameContactView}"/&gt; &lt;/Grid&gt; &lt;Grid HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20" RenderTransformOrigin="1.25,2.662"&gt; &lt;telerik:RadGridView x:Name="contactsGrid" GroupRenderMode="Flat" ItemsSource="{Binding Contacts}" PropertyChanged="{Binding Path=SelectedListNameContactView} AutoGenerateColumns="False" CanUserFreezeColumns="False" RowIndicatorVisibility="Collapsed" CanUserResizeColumns="True" Margin="5,5,5,5" IsReadOnly="True" &gt; &lt;telerik:RadGridView.Columns&gt; &lt;telerik:GridViewDataColumn Header="First Name" DataMemberBinding="{Binding FirstName}" Width="100" /&gt; &lt;telerik:GridViewDataColumn Header="Last Name" DataMemberBinding="{Binding LastName}" Width="100"/&gt; &lt;telerik:GridViewDataColumn Header="Address" DataMemberBinding="{Binding Address}" Width="200"/&gt; &lt;telerik:GridViewDataColumn Header="Address2" DataMemberBinding="{Binding Address2}" Width="75"/&gt; &lt;telerik:GridViewDataColumn Header="City" DataMemberBinding="{Binding City}" Width="75"/&gt; &lt;telerik:GridViewDataColumn Header="State" DataMemberBinding="{Binding State}" /&gt; &lt;telerik:GridViewDataColumn Header="Zip" DataMemberBinding="{Binding ZipCode}" Width="75"/&gt; &lt;telerik:GridViewDataColumn Header="Phone" DataMemberBinding="{Binding PhoneNumber}" Width="75"/&gt; &lt;telerik:GridViewDataColumn Header="Media Group" DataMemberBinding="{Binding MediaGroup}" Width="100"/&gt; &lt;telerik:GridViewDataColumn Header="Brochure Date" DataMemberBinding="{Binding BrochureDate}" Width="100"/&gt; &lt;/telerik:RadGridView.Columns&gt; &lt;/telerik:RadGridView&gt; &lt;/Grid&gt; &lt;/Grid&gt; </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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