wpf - Enable a button on slider values -
I have three sliders and one button. But button has one click event.
What do I need when in addition to enabling this button, the sum of the three slider values is greater than 0.
The code is simple, I think:
integer = total slider 1. Value + slider 2 Value + slider 3 Value; If Total & gt; 0 btnStart.Enable = true; Else btnStart.Enable = false;
Question I do not know where I want the code if I put it in the slider event, then three it has been repeated.
However, if we have many sliders, then is this method fool?
Just create a value /
event and attach it to your three sliders Eg:
Private Zero slider_changes current (object sender, routing property, chained events categories> double> gt; e) {btnStart. IsEnabled = (slider 1.Value & gt; 0 & amp; Slider 2. Value & gt; 0 & amp; Slider 3. Value & gt; 0); }
The XML will look like this:
& lt; Slider x: name = "slider1" ValueChanged = "Slider_ValueChanged" /> & Lt; Slider x: name = "slider 2" value change = "slider_view changelog" /> & Lt; Slider x: name = "slider 3" mangheng = "slider_whole changelog" />
Example of your button:
& lt; Button x: name = "btnStart" isEnabled = "False" & gt; & Lt; Button.Style & gt; & Lt; Style TargetType = "{x: type button}" & gt; & Lt; Setter Property = "IhiteTestVisible" Value = "True" /> & Lt; Setter property = "background" value = "red" /> & Lt; Setter Estates = "Template" & gt; & Lt; Setter.Value & gt; & Lt; ControlTemplate TargetType = "{x: type button}" & gt; & Lt; Border borderbrush = "{templatebiding borderbrush}" bordertyxize = "{without border description tagbacking}" background = "{templatebading background}" & gt; & Lt; ContentPresenter Content = "{TemplateBinding Content}" Vertical Alignment = "{Vertical Content Elementing TemplateBinding}" Horizontal Alignment = "{Horizontal Binding Horizontal Conference}" /> & Lt; / Border & gt; & Lt; / ControlTemplate & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; Style.Triggers & gt; & Lt; Trigger Property = "EzineABl" value = "False" & gt; & Lt; Setter Property = "IhiteTestVisible" value = "False" /> & Lt; Setter property = "background" value = "green" /> & Lt; / Catalyst & gt; & Lt; /Style.Triggers> & Lt; / Style & gt; & Lt; /Button.Style> & Lt; / Button & gt;
Comments
Post a Comment