Answer the question
In order to leave comments, you need to log in
How to use DependencyProperty?
Good afternoon. Started learning WPF (probably late, but better late than never).
And so, I cannot understand these properties of dependence together with a binding. I read a book - everything seems to be clear, but when it comes to writing - nothing happens.
Here's a simple question. Help me to understand.
Simple task:
The window has a Textbox (firstBox) in which only numbers can be entered.
Below is a slider (firstSlider) with a limit from 0 to 20
Even below TextBlock (secondBox)
How it works:
Numbers are entered
in firstBox When moving the slider firstSlider in secondBox, a number is displayed - firstBox * firstSlider.Value
How to do this using dependency properties? In plain language, please.
Answer the question
In order to leave comments, you need to log in
Write a converter that will implement IMultiValueConverter and multiply what comes to its input. In the xaml of secondBox, define the binding not as an attribute, but as an internal element, specifying your implementation and internal bindings as a converter.
Can at the same time and with understanding of commands help? )
Xaml:
<Menu.CommandBindings>
<CommandBinding Command="Copy" CanExecute="CommandBinding_OnCanExecute"></CommandBinding>
</Menu.CommandBindings>
<MenuItem Header="Edit" >
<MenuItem Header="Copy" Command="Copy"></MenuItem>
</MenuItem>
private void CommandBinding_OnCanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = false;
e.Handled = true;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question