Button Command not firing in UserControl WPF MVVM

I have a button command that is binded to a RelayCommand AddCommand whose code is located in my MainViewModel.cs. The problem I’m facing is the button I need the command to fire in is located in a usercontrol SettingsView.xaml.

When I bind the command to a button in my MainWindow.xaml, the ObservableCollection<PanelButton> PanelButton is udpated properly on click, but once I add the button command to a button in my SettingsView.xaml the event never fires.

Here is my MainViewModel.cs.

        public ObservableCollection<PanelButton> PanelButton { get; set; }

        public RelayCommand HomeViewCommand { get; set; }

        public RelayCommand SettingsViewCommand { get; set; }

        public RelayCommand AddCommand => new RelayCommand(execute => AddNavigationPanel());

        public StartingHomeViewModel HomeVM { get; set; }

        public SettingsViewModel SettingsVM { get; set; }

        private object _currentView;

        public object CurrentView
        {
            get { return _currentView; }
            set
            {
                _currentView = value;
                OnPropertyChanged();
            }

        }

        private PanelButton selectedPanelButton;

        public PanelButton SelectedPanelButton
        {
            get { return selectedPanelButton; }
            set 
            { 
                selectedPanelButton = value; 
                OnPropertyChanged();
            }
        }

        public MainViewModel()
        {

            PanelButton = new ObservableCollection<PanelButton>();
            panelHandler = new PanelHandler();

            HomeVM = new StartingHomeViewModel();
            SettingsVM = new SettingsViewModel();

            CurrentView = HomeVM;

            HomeViewCommand = new RelayCommand(o =>
            {
                CurrentView = HomeVM;
            });

            SettingsViewCommand = new RelayCommand(o =>
            {
                CurrentView = SettingsVM;
            });


            ShowNavigationPanels();
        }

        private void ShowNavigationPanels()
        {
            foreach (string name in panelHandler.PanelNameCollection())
            {
                PanelButton.Add(new PanelButton
                {
                    Name = name
                });
            }
        }

        private void AddNavigationPanel()
        {
            MessageBox.Show("it works", "success", MessageBoxButton.OK, MessageBoxImage.Exclamation);

            panelHandler.CreatePanel("test panel 1");
            PanelButton.Add(new PanelButton
            {
                Name = "test panel 1"
            });

        }

Here is my MainWindow.xaml

                    <Window.DataContext>
                        <viewModel:MainViewModel/>
                    </Window.DataContext>

                    <ItemsControl ItemsSource="{Binding PanelButton}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <RadioButton Style="{StaticResource MenuButtonTheme}"
                                             Content="{Binding Name}"
                                             Height="50"
                                             FontSize="14"/>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>

                    <ContentControl Grid.Row="1"
                            Grid.Column="1"
                            Margin="0"
                            Padding="5"
                            Content="{Binding CurrentView}"/>

Here is my SettingsView.xaml

    <UserControl.DataContext>
        <viewmodel:MainViewModel/>
    </UserControl.DataContext>

<Button Background="white"
        Height="30"
        Width="200"
        HorizontalAlignment="Left"
        Margin="10,10,0,0"
        Content="Create"
        Style="{StaticResource RegularButton}"
        Command="{Binding AddCommand}"/>

Here is my App.xaml

    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Theme/MenuButtonTheme.xaml"/>
                <ResourceDictionary Source="Theme/SearchTheme.xaml"/>
                <ResourceDictionary Source="Theme/RegularButtonTheme.xaml"/>
                <ResourceDictionary Source="Theme/ScrollbarTheme.xaml"/>
                <ResourceDictionary Source="Theme/SettingsTabTheme.xaml"/>
                <ResourceDictionary Source="Theme/PanelNavigationTheme.xaml"/>
            </ResourceDictionary.MergedDictionaries>

            <DataTemplate DataType="{x:Type viewModel:StartingHomeViewModel}">
                <view:StartingHomeView/>
            </DataTemplate>

            <DataTemplate DataType="{x:Type viewModel:SettingsViewModel}">
                <view:SettingsView/>
            </DataTemplate>

        </ResourceDictionary>
    </Application.Resources>

EDIT

I added DataContext to SettingsView, which now fires the event which brings another problem. The event fires, prompting the messagebox, but now the ObservableCollection<PanelButton> PanelButton doesn’t update when fired. Any ideas why this might be happening?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật