N
N
Nubzilo2015-04-12 19:12:42
WPF
Nubzilo, 2015-04-12 19:12:42

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

2 answer(s)
L
lam0x86, 2015-04-12
@Nubzilo

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.

N
Nubzilo, 2015-04-17
@Nubzilo

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>

In codebehind:
private void CommandBinding_OnCanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = false;
e.Handled = true;
}

Although the button is visually disabled and you can’t click on it, does the hotkey (Ctrl + C) work on text?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question