<Window x:Class="Wpf_School_Announce.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:Wpf_School_Announce" xmlns:vm="clr-namespace:Wpf_School_Announce.ViewModels" mc:Ignorable="d" Title="Announcements" Height="236.436" Width="293.218"> <Window.Resources> <vm:ViewModelBase x:Key="viewModel"/> </Window.Resources> <Grid DataContext="{Binding Source=viewModel}"> <StackPanel Margin="0,10"> <Button x:Name="btn1stBell" Content="1st Bell" HorizontalAlignment="Center" VerticalAlignment="Top" Width="75" Margin="0,10" Command="{Binding ParameterCommand, Source={StaticResource viewModel}}" CommandParameter="{Binding Command, ElementName=btn1stBell}"/> <Button x:Name="btnLunchMenu" Content="Lunch Menu" HorizontalAlignment="Center" VerticalAlignment="Top" Width="75" Margin="0,10" Command="{Binding ParameterCommand, Source={StaticResource viewModel}}" CommandParameter="{Binding Command, ElementName=LunchMenu}"/> </StackPanel> </Grid> </Window> namespace Wpf_School_Announce.ViewModels { public class ViewModelBase { public ParameterCommand ParameterCommand { get; set; } public ViewModelBase() { ParameterCommand = new ParameterCommand(this); } public void ParameterMethod(string <Not sure what needs to go here>) { Debug.WriteLine("Parameter Comand:{0}", AnnoucementModel); //Todo: Need to find out which UI button was clicked to direct The Speech Synthesozer to the correct Speech Text. } } } namespace Wpf_School_Announce.ViewModels.Commands { public class ParameterCommand : ICommand { public ViewModelBase ViewModel { get; set; } public ParameterCommand(ViewModelBase viewModel) { ViewModel = viewModel; } public event EventHandler CanExecuteChanged; public bool CanExecute(object parameter) { return true; } public void Execute(object parameter) { ViewModel.ParameterMethod(parameter as String); } } }
SelectedItem
CommandParameter
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)