I'm doing an WPF UserControl
.
Inside of this UserControl, I've several Button
that can be used on certains conditions, so binding them to a command is perfect.
The command called by those Buttons should not be available outside of the UserControl.
If I make my Commands private, the XAML of the UserControl
says that he wants public member.
So, what is the way to go to have one UserControl that has several commands internally, but not available outside of the UserControl?
Example:
<Wizard CanGoPrevious="{Binding SomeViewModelProperty}">
<WizardPage>
<TextBlock>Page one</TextBlock>
</WizardPage>
</Wizard>
Wizard's XAML:
<DockPanel DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type wizard:Wizard}}}" LastChildFill="True">
<StackPanel Orientation="Horizontal" DockPanel.Dock="Bottom" HorizontalAlignment="Right">
<Button Content="{Binding PreviousButtonText}" Command="{Binding GoToPreviousPageCommand}"/>
</StackPanel>
<ContentControl ></ContentControl>
</DockPanel>
Wizard's Code behind:
//Protected doesn't work. Also, this command should not be available outside of the Wizard `UserControl`
protected DelegateCommand GoToPreviousPageCommand { get; set; }
Which is assigned like this in the constructor
GoToPreviousPageCommand = new DelegateCommand(GoToPreviousPage, CanGoToPreviousPage);
private void GoToPreviousPage()
{
//[...]
}
private bool CanGoToNextPage()
{
//Some usage of the Wizard's DP:
return CanGoPrevious //&& some other stuff
}