Use Commands with RadRibbonView Buttons in C# and not XAML - c#

I am trying to get MVVM (pretty new to it) and RadRibbonView to work together. Problem is, I was working with a standard WPF application with an MVVM model.
In the XAML file I previously had.
<Menu>
<MenuItem Header="{x:Static properties:Resources.FileMenu}">
<MenuItem Header="{x:Static properties:Resources.FileMenuNewWorkflow}" Command="{Binding Path=NewWorkflowCommand}" InputGestureText="Ctrl+N"/>
<MenuItem Header="{x:Static properties:Resources.FileMenuNewService}" Command="{Binding Path=NewServiceCommand}" InputGestureText="Shift+Ctrl+N"/>
<MenuItem Header="{x:Static properties:Resources.FileMenuOpen}" Command="{Binding Path=OpenWorkflowCommand}" InputGestureText="Ctrl+O"/>
<Separator/>
<MenuItem Header="{x:Static properties:Resources.FileMenuSave}" Command="{Binding Path=SaveWorkflowCommand}" InputGestureText="Ctrl+S"/>
<MenuItem Header="{x:Static properties:Resources.FileMenuSaveAs}" Command="{Binding Path=SaveAsWorkflowCommand}"/>
<MenuItem Header="{x:Static properties:Resources.FileMenuSaveAll}" Command="{Binding Path=SaveAllWorkflowsCommand}" InputGestureText="Shift+Ctrl+S"/>
<Separator/>
<MenuItem Header="{x:Static properties:Resources.FileMenuAddReference}" Command="{Binding Path=AddReferenceCommand}"/>
<Separator/>
<MenuItem Header="{x:Static properties:Resources.FileMenuClose}" Command="{Binding Path=CloseWorkflowCommand}"/>
<MenuItem Header="{x:Static properties:Resources.FileMenuCloseAll}" Command="{Binding Path=CloseAllWorkflowsCommand}"/>
<Separator/>
</Menu>
RelayCommand.cs
public class RelayCommand : ICommand
{
private readonly Action<object> execute;
private readonly Predicate<object> canExecute;
public RelayCommand(Action<object> execute)
: this(execute, null)
{
}
public RelayCommand(Action<object> execute, Predicate<object> canExecute)
{
if (execute == null)
{
throw new ArgumentNullException("execute");
}
this.execute = execute;
this.canExecute = canExecute;
}
public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
public bool CanExecute(object parameter)
{
return this.canExecute == null ? true : this.canExecute(parameter);
}
public void Execute(object parameter)
{
this.execute(parameter);
}
}
As you can see the Command id was well defined. I wanted to add Ribbon to this and selected RibbonView from telerik WPF UI. Picked the Paint with MVVM model.
Converted the Menu to Ribbon
<telerik:RadRibbonView Grid.Row="0" x:Name="ribbonView" ApplicationName="MyApp" ItemsSource="{Binding Tabs}"
ApplicationButtonContent="File" Title="{x:Static properties:Resources.RibbonViewTitle}" ItemTemplate="{StaticResource TabTemplate}"
SelectedItem="{Binding SelectedTab, Mode=TwoWay}"
MinimizeButtonVisibility="Visible" HelpButtonVisibility="Visible">
In the MainWindowModelView The following is defined. SplitButtonViewModel inherits from ButtonViewModel.
private GroupViewModel GetFilesGroup()
{
GroupViewModel fileItems = new GroupViewModel();
fileItems.Text = "File";
SplitButtonViewModel newFile = new SplitButtonViewModel();
newFile.Text = "New";
newFile.Size = ButtonSize.Large;
newFile.LargeImage = GetPath("MVVM/new.png");
fileItems.Buttons.Add(newFile);
SplitButtonViewModel openFile = new SplitButtonViewModel();
openFile.Text = "Open";
openFile.Size = ButtonSize.Large;
openFile.LargeImage = GetPath("MVVM/open.png");
fileItems.Buttons.Add(openFile);
ButtonGroupViewModel buttonsGroup = new ButtonGroupViewModel();
buttonsGroup.Buttons.Add(GetButton("save", "Save"));
buttonsGroup.Buttons.Add(GetButton("SaveAll", "Save All"));
buttonsGroup.Buttons.Add(GetButton("SaveAs", "Save As"));
fileItems.Buttons.Add(buttonsGroup);
return fileItems;
}
My current ButtonViewModel from the telerik MVVM Ribbon example is
public class ButtonViewModel : ViewModelBase
{
private String text;
private ButtonSize size;
private string smallImage;
private string largeImage;
//perhaps work something with this...
private RelayCommand command;
/// <summary>
/// Gets or sets Text.
/// </summary>
public String Text
{
get
{
return this.text;
}
set
{
if (this.text != value)
{
this.text = value;
this.OnPropertyChanged("Text");
}
}
}
public ButtonSize Size
{
get
{
return size;
}
set
{
size = value;
}
}
public string SmallImage
{
get
{
return smallImage;
}
set
{
smallImage = value;
}
}
public string LargeImage
{
get
{
return largeImage;
}
set
{
largeImage = value;
}
}
}
So all the creation of the Groups is in the ModelView. The problem is I am not sure how to get the Command working. I have a RelayCommand class which takes care of the commands.
From the following link: http://docs.telerik.com/devtools/wpf/controls/radribbonview/how-to/howto-use-commands-with-radribbonview-buttons
Is it possible to just call the class RelayCommand (basically same as the example from the link), so I do not have to change much and just invoke the command from the above function? Something like openFile.Execute() or something.
Most of the questions were how to connect XAML to Commands. All the menu items are now in C# and wanted a command definition there.
Any help is appreciated.

Related

WPF MVVM Listview : Is Leftdoubleclick need write event?

I wrote update function, I want to when I double-click a data in the listview, data will be shown in a textbox. I search and find many solutions,
I have a example:
`<ListView ItemsSource="{Binding listHocVien}"
SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}">
<ListView.InputBindings>
<MouseBinding MouseAction="LeftDoubleClick" />
</ListView.InputBindings>
<ListView.View>
<GridView>
<GridViewColumn Header="Name"
DisplayMemberBinding="{Binding Name}">
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>`
But I when I run the app and click data, I just need one click, not double-click.
I have to find the solution on the internet and didn't see anyone said to write an event for LeftDoubleClick.
So, did we need to write the event to LeftDoubleClick? If yes, can anyone show me examples.
Thank for all your help.
You could use behaviours:
How to add System.Windows.Interactivity to project?.
This way you could create a double click command and bind it to your view model class. In the execute of your command you could set the property of the textbox to the desired text
After you've added in your project you should reference the namespace in the xaml code. If you reference it as i then your code to add the behaviour to the list view should be as follows:
In your xaml:
<TextBox Text ="{Binding Text, UpdateSourceTrigger=PropertyChanged}"/>
<ListView>
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick">
<i:InvokeCommandAction Command="{Binding YourCommand}"
CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ListView>
In your View Model:
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Input;
public class SampleViewModel : INotifyPropertyChanged {
private string _Text;
public event PropertyChangedEventHandler PropertyChanged;
public string Text {
get { return _Text; }
set {
if (_Text != value) {
_Text = value;
RaisePropertyChanged();
}
}
}
public ICommand YourCommand { get; set; }
public SampleViewModel() {
YourCommand = new RelayCommand<TType>(YourCommandExecute); // that TType is the type of your elements in the listview
}
// Here I will assume that your TType has a property named Description
private void YourCommandExecute(TType selectedElement) {
Text = selectedItem.Description;
}
public void RaisePropertyChanged([CallerMemberName] propertyName = null) {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
Relay Command Implementation
// Simple Implementation of Generic Relay Command:
public class RelayCommand<T> : ICommand
{
private Action<T> execute;
private Func<T,bool> canExecute;
public event EventHandler CanExecuteChanged;
public RelayCommand(Action<T> execute,Func<T,bool> canExecute=null)
{
this.execute = execute;
this.canExecute = canExecute;
}
public bool CanExecute(object parameter)
{
return canExecute == null || canExecute((T)parameter);
}
public void Execute(object parameter)
{
execute((T)parameter);
}
}

How to access CommandTarget from ContextMenu Command?

I have a ContextMenu that suppose to set value on its parent TextBox.
The textbox cannot have a name (by requirement), so I am setting it as CommandTarget
<TextBox Text="{Binding TextBoxOne, UpdateSourceTrigger=LostFocus}">
<TextBox.ContextMenu>
<ContextMenu>
<MenuItem Header="Set to 35"
Command="{Binding SetAmountCommand}"
CommandParameter="35"
CommandTarget="{Binding Text, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TextBox}}}" />
<MenuItem Header="Set to 50"
Command="{Binding SetAmountCommand}"
CommandParameter="50"
CommandTarget="{Binding Text, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TextBox}}}" />
</ContextMenu>
</TextBox.ContextMenu>
How to access the TextBox.Text from inside the Command ?
ViewModel
public class MainVm : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public string TextBoxOne { get; set; } = "One";
private ICommand _setAmountCommand;
public ICommand SetAmountCommand
{
get
{
return _setAmountCommand ?? (_setAmountCommand = new CommandParameterHandler((o) =>
{
object param = o;
double amount = (double)o;
//MyParentTextBox.Text = amount; //What to put here ? (Cannot be TextBoxOne = amount, need to route from View)
}, true));
}
}
}
Generic CommandParameterHandler
public class CommandParameterHandler : ICommand
{
private Action<object> _action;
private bool _canExecute;
public CommandParameterHandler(Action<object> action, bool canExecute)
{
_action = action;
_canExecute = canExecute;
}
public bool CanExecute(object parameter)
{
return _canExecute;
}
public event EventHandler CanExecuteChanged;
public void Execute(object parameter)
{
_action(parameter);
}
}
You can only pass one CommandParameter to the command. If you want to pass is something in addition to the actual value, you could create a custom composite type that carries more than one value:
public class CompositeParameter : Freezable
{
protected override Freezable CreateInstanceCore()
{
return this;
}
public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(nameof(Value),
typeof(string), typeof(CompositeParameter));
public string Value
{
get { return (string)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}
public static readonly DependencyProperty ControlProperty = DependencyProperty.Register(nameof(Control),
typeof(FrameworkElement), typeof(CompositeParameter));
public FrameworkElement Control
{
get { return (FrameworkElement)GetValue(ControlProperty); }
set { SetValue(ControlProperty, value); }
}
}
View Model:
public ICommand SetAmountCommand
{
get
{
return _setAmountCommand ?? (_setAmountCommand = new CommandParameterHandler((o) =>
{
CompositeParameter param = o as CompositeParameter;
if (param != null)
{
double amount = Convert.ToDouble(param.Value);
//...
TextBox textBox = param.Control as TextBox;
if (textBox != null)
textBox.Text = param.Value;
}
}, true));
}
}
View:
<TextBox Text="{Binding TextBoxOne, UpdateSourceTrigger=LostFocus}">
<TextBox.ContextMenu>
<ContextMenu>
<ContextMenu.Resources>
<local:CompositeParameter x:Key="paramA"
Value="35"
Control="{Binding PlacementTarget, RelativeSource={RelativeSource AncestorType=ContextMenu}}" />
<local:CompositeParameter x:Key="paramB"
Value="50"
Control="{Binding PlacementTarget, RelativeSource={RelativeSource AncestorType=ContextMenu}}" />
</ContextMenu.Resources>
<MenuItem Header="Set to 35"
Command="{Binding SetAmountCommand}"
CommandParameter="{StaticResource paramA}" />
<MenuItem Header="Set to 50"
Command="{Binding SetAmountCommand}"
CommandParameter="{StaticResource paramB}" />
</ContextMenu>
</TextBox.ContextMenu>
</TextBox>
After 2 days searching for answer, I came across this RoutedCommand tutorial. Yes, you can access CommandTarget from Command, but it has to be a static RoutedCommand. This approach fits the need as SetAmountCommand is shared by multiple MenuItem.
XAML
<Window x:Class="WpfCommandTargetDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfCommandTargetDemo">
<Window.CommandBindings>
<CommandBinding CanExecute="SetAmountCommand_CanExecute"
Command="{x:Static local:CustomRoutedCommand.SetAmountCommand}"
Executed="SetAmountCommand_Executed" />
</Window.CommandBindings>
<StackPanel>
<TextBox Text="{Binding TextBoxOne, UpdateSourceTrigger=LostFocus}">
<TextBox.ContextMenu>
<ContextMenu>
<MenuItem Header="Set to 35"
Command="{x:Static local:CustomRoutedCommand.SetAmountCommand}"
CommandParameter="35"
CommandTarget="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ContextMenu}, Path=PlacementTarget}" />
<MenuItem Header="Set to 50"
Command="{x:Static local:CustomRoutedCommand.SetAmountCommand}"
CommandParameter="50"
CommandTarget="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ContextMenu}, Path=PlacementTarget}" />
</ContextMenu>
</TextBox.ContextMenu>
</TextBox>
</StackPanel>
</Window>
CodeBehind
public partial class MainWindow : Window
{
private readonly MainVm _mainVm;
public MainWindow()
{
InitializeComponent();
_mainVm = new MainVm();
DataContext = _mainVm;
}
void SetAmountCommand_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}
void SetAmountCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
object param = e.Parameter; //CommandParameter
TextBox textbox = e.OriginalSource as TextBox; //CommandTarget
if (textbox != null)
{
textbox.Text = param.ToString();
}
}
}
RoutedCommand has to be static, because it is statically bound to XAML element.
public static class CustomRoutedCommand
{
public static readonly RoutedCommand SetAmountCommand = new RoutedCommand();
}
For completeness, I cannot have the Command on my ViewModel. SetAmountCommand property is removed.
public class MainVm : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public string TextBoxOne { get; set; } = "One";
}

How to pass information about selected item from DataGrid using MVVM

I'm doing my first app using MVVM. I have in "View" declared Datagrid. Code XAML below:
<DataGridTemplateColumn Header="delete">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button
Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type> UserControl},Mode=FindAncestor}, Path=DataContext.ClickCommand}"> Content="X" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>>
</DataGrid>
In my ViewModel class I can run function that I want after click button "delete" by part of code:
public ICommand ClickCommand => _clickCommand ?? (_clickCommand = new CommandHandler(Delete, _canExecute));
public void Delete()
{
// DataTable.Rows.RemoveAt();
}
I have problem because I can't get index of selectet row. Source of data in datagrid is dataTable.
Do you have any ideas how to do this?
I've tried something with passing parameter with command of button but I coudn't make it works.
Xmal code
<Button Command="{Binding Path=DataContext.ViewCommand,RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" CommandParameter="{Binding Id}" Content="X" Background="Chocolate"/>
Codebehind code
public RelayCommand DeleteCommand
{
get
{
return new RelayCommand(p => Delete(p));
}
}
public void Delete(string id)
{
// DataTable.Rows.RemoveAt();
}
This is example you can pass whatever you want in that cmd parameter.
Relay cmd
public class RelayCommand : ICommand
{
private Action<object> action;
private Func<bool> canFuncPerform;
public event EventHandler CanExecuteChanged;
public RelayCommand(Action<object> executeMethod)
{
action = executeMethod;
}
public RelayCommand(Action<object> executeMethod, Func<bool> canExecuteMethod)
{
action = executeMethod;
canFuncPerform = canExecuteMethod;
}
public void RaiseCanExecuteChanged()
{
CanExecuteChanged(this, EventArgs.Empty);
}
public bool CanExecute(object parameter)
{
if (canFuncPerform != null)
{
return canFuncPerform();
}
if (action != null)
{
return true;
}
return false;
}
public void Execute(object parameter)
{
if (action != null)
{
action(parameter);
}
}
}
You shouldn't rely on the selected item. Instead pass the current row item as CommandParameter:
<DataGridTemplateColumn Header="delete">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button
Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl},Mode=FindAncestor}, Path=DataContext.ClickCommand}"
CommandParameter="{Binding}"
Content="X" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Then of course, use an ICommand implementation that is not discarding the command parameter and use it to identify the row to be deleted.

How to use MVVM Icommand on button? [duplicate]

This question already has answers here:
Bind button in DataTemplate to command in the form's ViewModel
(2 answers)
Closed 6 years ago.
I have a list that load items from an observable collection ComputerList
<ListView x:Name="icTodoList" ItemsSource="{Binding ComputerList}" SelectedItem="{Binding SelectedComputer}" Grid.Column="3" SelectionChanged="icTodoList_SelectionChanged_1">
<ListView.ItemTemplate>
<DataTemplate>
<Border BorderBrush="{Binding borderColor }" BorderThickness="2" Margin="0,0,0,1">
<Grid Margin="2" Height="auto" Width="auto">
<Button Height="18" Command="{Binding RemoveComputer}" HorizontalAlignment="Right" ToolTipService.ShowDuration="60000" Margin="0,1,38,0" x:Name="button1_Copy" VerticalAlignment="Top" Width="25" FontSize="11" Foreground="#FF6BADF6" Content="" BorderBrush="#FF6BADF6" Grid.Column="8"/>
</Grid>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
my button click should remove the items from observableCollection so i did build Icommand interface this way (in short version).
class ComputerViewModel : ViewModelBase
{
CustomClass _customClass = new CustomClass();
public readonly ObservableCollection<Model.Model.ControleData> _ComputerList = new ObservableCollection<Model.Model.ControleData>();
public ObservableCollection<Model.Model.ControleData> ComputerList { get { return _ComputerList; } }
public ComputerViewModel()
{
ComputerList.Add(new Model.Model.ControleData { ComputerName = "TESTMACHINE", titlePing = "online",borderColor = Genkai.BlueMain });
// TextBoxText = "init";
_canExecute = true;
}
private ICommand _RemoveComputer;
public ICommand RemoveComputer
{
get
{
return _RemoveComputer ?? (_RemoveComputer = new CommandHandler(() => RemoveComp(), _canExecute));
}
}
private bool _canExecute;
public void RemoveComp()
{
Debug.WriteLine("close Item");
}
public class CommandHandler : ICommand
{
private Action _action;
private bool _canExecute;
public CommandHandler(Action action, bool canExecute)
{
_action = action;
_canExecute = canExecute;
}
public void Execute(object parameter)
{
_action();
}
public bool CanExecute(object parameter)
{
return _canExecute;
}
public event EventHandler CanExecuteChanged;
}
}
the action removecomp is not fired when i click.
but with this in my view model its fired
var hwc = new CommandHandler(RemoveComp,true);
if (hwc.CanExecute(this))
hwc.Execute(this);
so i guess i miss something in my WPF view.
You are trying to bind VM commands in datatemplate. It cannot find this command, because it has different context.
try to bind in that way
Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:TypeOfYourControlOrWindow}}, Path=DataContext.YourCommand}"

Cannot hit the getter of Property

I am trying to use AvalonDock in Prism. All works fine except MenuItem "Tools->Properties". The MenuItem "File->New" works fine - new window is created and I can dock wherever I want.
This code works okay in simple MVVM application(without Prism) – “MenuItem” is fired always.
What I have:
<UserControl x:Class="ModuleCAvalonDock.ViewC">
<Menu>
<MenuItem Header="File">
<MenuItem Header="New" Command="{Binding NewCommand}"/>
<MenuItem Header="Open" Command="{Binding OpenCommand}"/>
<Separator/>
<MenuItem Header="Save" Command="{Binding ActiveDocument.SaveCommand}"/>
<MenuItem Header="Save As..." Command="{Binding ActiveDocument.SaveAsCommand}"/>
<Separator/>
<MenuItem Header="Close" Command="{Binding ActiveDocument.CloseCommand}"/>
</MenuItem>
<MenuItem Header="Tools">
<MenuItem Header="Properties" IsChecked="{Binding FileStats.IsVisible, Mode=TwoWay}" IsCheckable="True"/>
</MenuItem>
<MenuItem Header="Layout">
<MenuItem Header="Load" Command="{Binding LoadLayoutCommand, ElementName=mainWindow}"/>
<MenuItem Header="Save" Command="{Binding SaveLayoutCommand, ElementName=mainWindow}"/>
<MenuItem Header="Dump to Console" Click="OnDumpToConsole"/>
</MenuItem>
</Menu>
</UserControl>
How I am binding:
public ViewC(IViewModel viewModel)
{
InitializeComponent();
this.DataContext = Workspace.This;
}
and ViewModel:
public class Workspace:ViewModelBase
{
FileStatsViewModel _fileStats = null;
public FileStatsViewModel FileStats
{
get
{
if (_fileStats == null)
_fileStats = new FileStatsViewModel();
return _fileStats;
}
}
RelayCommand _newCommand = null;
public ICommand NewCommand
{
get
{
if (_newCommand == null)
{
_newCommand = new RelayCommand((p) => OnNew(p), (p) => CanNew(p));
}
return _newCommand;
}
}
private bool CanNew(object parameter)
{
return true;
}
private void OnNew(object parameter)
{
_files.Add(new FileViewModel());
ActiveDocument = _files.Last();
}
protected Workspace()
{
}
static Workspace _this = new Workspace();
public static Workspace This
{
get { return _this; }
}
}
FileStatsViewModel:
public class FileStatsViewModel : ToolViewModel { }
public class ToolViewModel
{
private bool _isVisible = true;
public bool IsVisible
{
get { return _isVisible; }
set
{
if (_isVisible != value)
{
_isVisible = value;
RaisePropertyChanged("IsVisible");
}
}
}
}
However, It does not work in Prism. I’ve tried setting some break point to check if the property is fired and FileStats property is firing in simple MVVM application, but FileStats property is not firing in Prism application!
The code where I initialize my View:
public class ModuleCModule: ModuleBase
{
public ModuleCModule(IUnityContainer container, IRegionManager regionManager)
: base(container, regionManager) { }
protected override void InitializeModule()
{
RegionManager.RegisterViewWithRegion(RegionNames.ContentRegion, typeof(ViewC));
}
protected override void RegisterTypes()
{
Container.RegisterTypeForNavigation<ViewC>();
}
}
It is really interesting that I can fire my command <MenuItem Header="New" Command="{Binding NewCommand}"/>. However, I cannot fire property FileStats at viewModel Workspace.
How to fire my property? What am I doing wrong?
Prism has no impact on the WPF binding system, so this is an issue with how you are creating the binding to the DataContext of the view. How are you assigning the ViewModel to the DataContext of your View? Check your output window for binding errors. Chances are your DataContext is not being set.
If you are using the ViewModelLocator, then make sure you are following the proper naming conventions:
http://brianlagunas.com/getting-started-prisms-new-viewmodellocator/
EDIT: I ran your app as is, and was able to hit the setter on your FileStats.IsVisible property. If you are placing a breakpoint on the getter of FileStats, well that won't fire when you click on the menu item, because you are bound to a property of FileStats, not FileStats which is read-only anyways. By the way, you know Prism 6.1 is out (you're using v4). Also, you should try using NuGet instead of hard references.

Categories

Resources