I have a custom Button as follows:
<UserControl...>
<Button HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Viewbox Stretch="Uniform" Grid.Column="0">
<TextBlock x:Name="numCopyTB" Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Path=Text}"/>
</Viewbox>
<Viewbox Grid.Column="1">
<TextBlock Style="{StaticResource updownBlock}"/>
</Viewbox>
</Grid>
</Button>
</UserControl>
in its code behind, I added its Text Property. Code behind is below:
public partial class UpdownButton : UserControl
{
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(string), typeof(UpdownButton));
public UpdownButton()
{
InitializeComponent();
}
public string Text
{
get { return GetValue(TextProperty) as string; }
set { SetValue(TextProperty, value); }
}
}
I am learning about CommandBinding and would like to be able to do something like <local:MyCustomButton Command="{Binding MethodName}"/>.
It seems that I need to add a Command Property in codebehind, but what Type should Command be? I did some search and there seems to be many possibilities: RoutedUICommand, RoutedCommand, CommandBinding, DelegateCommand etc., and I am quite lost. Any help is appreciated!