Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Get Value of selected checked box item using mvvm

$
0
0

Hi,

Below is my xaml code

<StackPanel Orientation="Vertical">
                        <ListBox x:Name="_category" ItemsSource="{Binding CaseCategories}" Background="#FCF9F2" BorderBrush="#FCF9F2"  Foreground="#344C78">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <CheckBox Margin="4,14,0,0" Width="3.6in" Content="{Binding Category, Mode=TwoWay}"
                                            IsChecked="{Binding Path=IsChecked, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" >
                                    </CheckBox>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </StackPanel>

On viewmodel 

CaseCategories = new ObservableCollection<CaseFlagypeViewModel>();
            var q = DmsEntitiesDB.CaseFlagTypes.Where(x => x.Id == 14).ToList();
            foreach (var a in q)
            {
                var b = a.ViewModel;
                CaseCategories.Add(b);

            }
            categoryLookup = CaseCategories;


I want toget the value of checked item and save it in the db.

Can someone suggest how to get the value of checked item using mvvm. i can go from there



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>