ComboBox just don't work in wpf mvvm

I’m pretty desperate. I have a wpf project the view is so that there is on the left half an ListView on the other half (right side) there is som controls. Labels, Textbox CheckBox and a ComboBox.

When loading the program I set the ListView with a list of Category. In this Category I have an item called ProjectName. If a category has a project there will the projectName be listet. And I also make a list of Projects in the ComboBox.

When selecting a row in the ListView I add the row to an SelectedCategory this for later saving that row.

Now when selecting a row in the ListView I want it to change the controls to the info of the selected row. This works fine for all except for the ComboBox. I am not able, and believe me I have tried a lot of things, to make the combobox selectedItem/-Value the same as the selected rows ProjectName. An also the other way round - when selecting a projectName in the comboBox it won’t set the selected row in the ListView.

I have made two textboxes to see if the selected value for the ListViews ProjectId and ProjectName are valid. And they are. When changing the value in the textboxes the value in the ListView are changed.

So how can I make it so, that when clicking on the Listviews row that specific (if there is on) row in the comboBox?`

My ListView
> <ListView x:Name=“LivCategories” ItemsSource="{Binding Categories_GetActive}"

                          SelectedItem="{Binding SelectedCategory}" Grid.Row="0" Grid.Column="0">
                            <GridViewColumn Header="Id" Width="50" DisplayMemberBinding="{Binding CategoryId}"/>
                            <GridViewColumn Header="Navn" Width="250"  DisplayMemberBinding="{Binding CategoryName}"/>
                            <GridViewColumn Header="Global" Width="50"  DisplayMemberBinding="{Binding CategoryIsGlobal}"/>
                            <GridViewColumn Header="Project" Width="150"  DisplayMemberBinding="{Binding ProjectName}"/>
                            <GridViewColumn Header="ProjectId" Width="0"  DisplayMemberBinding="{Binding ProjectId}" />

My comboBox and two textboxes

                        <TextBox x:Name="TxtProjectId" Margin="0 0 8 0" Text="{Binding ElementName=LivCategories, Path = SelectedValue.ProjectId, Mode = TwoWay}" Grid.Row="6" Grid.Column="1" Height="25" />
                        <TextBox x:Name="TxtProjectName" Margin="0 0 8 0" Text="{Binding ElementName=LivCategories, Path = SelectedValue.ProjectName, Mode = TwoWay}" Grid.Row="6" Grid.Column="2" Height="25" />

My SelectedCategory in the ViewModel
private Category _selectedCategory;
public MyICommand DeleteCommand { get; set; }

    public Category SelectedCategory
            return _selectedCategory;

            _selectedCategory = value;

If you need more code, just say so :slight_smile:

I don’t know where the combobox went but here it is

<ComboBox x:Name="CbxProject" Text="Projekt" Grid.Row="5" Grid.Column="2" HorizontalContentAlignment="Left"  VerticalContentAlignment="Center"
                                      ItemsSource="{Binding Projects_GetActive}" DisplayMemberPath="ProjectName" 
                                      SelectedValue="{Binding LivCategories}">

A nice man told me what to do

> <ComboBox x:Name="CbxProject" Grid.Row="5" Grid.Column="2" HorizontalContentAlignment="Left"  VerticalContentAlignment="Center"
>                                       ItemsSource="{Binding Path=Projects_GetActive}" DisplayMemberPath="ProjectName" 
>                                       Text="{Binding ElementName=LivCategories, Path=SelectedValue.ProjectName}">
>                             </ComboBox>
.NET Foundation Website | Blog | Projects | Code of Conduct