wpf - How to find the thumb of a slider to set its width -
i creating "range slider" 3 slider controls stacked on top of each other. basic idea here uses 2 sliders.
i'm adding third slider thumb fill space between the thumbs other slider. user able drag center thumb move 2 ends , maintain constant spacing between 2 ends.
the xaml 3 sliders. secret getting layer nicely in using control template (not reprodiced here. can find @ above url).
<grid verticalalignment="top"> <border borderthickness="0,1,0,0" borderbrush="green" verticalalignment="center" height="1" margin="5,0,5,0"/> <slider x:name="lowerslider" minimum="{binding elementname=root, path=minimum}" maximum="{binding elementname=root, path=maximum}" value="{binding elementname=root, path=lowervalue, mode=twoway}" margin="0,0,0,0" template="{staticresource simpleslider}" /> <slider x:name="middleslider" minimum="{binding elementname=root, path=minimum}" maximum="{binding elementname=root, path=maximum}" value="{binding elementname=root, path=middlevalue, mode=twoway}" margin="10,0,0,0" template="{staticresource simpleslider}" > </slider> <slider x:name="upperslider" minimum="{binding elementname=root, path=minimum}" maximum="{binding elementname=root, path=maximum}" value="{binding elementname=root, path=uppervalue, mode=twoway}" margin="20,0,0,0" template="{staticresource simpleslider}" /> </grid>
as either outer thumb dragged, need resize center thumb fill space between 2 end thumbs.
in code behind, can catch movement of thumb, , can find middle slider control, can't figure out how programatically thumb of middle slider can resize fill space between 2 outer thumbs.
private void upperslider_valuechanged(object sender, routedpropertychangedeventargs<double> e) { slider slider= (slider) this.findname("middleslider"); // how find middleslider thumb can set // it's width fill space between outer thumbs }
thanks ideas,
mitch
this should it:
var track = (track)slider.template.findname("part_track", slider); var thumb = track.thumb; thumb.width = fittingwidth;
(by way, not way, apply multibinding
2 other sliders , converter calculates width that)
Comments
Post a Comment