c# - EventTrigger based on several other controls being given focus -
i have togglebutton
:
<togglebutton x:name="buttonstudentpicker" content="student picker" horizontalalignment="right" margin="2,10,2,10" borderthickness="0,5,0,0" background="{x:null}"> <togglebutton.layouttransform> <rotatetransform angle="90"/> </togglebutton.layouttransform> <togglebutton.style> <style targettype="togglebutton"> <style.triggers> <datatrigger binding="{binding elementname=buttonbiblereadingmain, path=isfocused, mode=oneway}" value="true"> <setter property="ischecked" value="true"/> </datatrigger> </style.triggers> </style> </togglebutton.style> </togglebutton>
i have 2 related issues. firstly, have several elements on interface cause button toggle on. @ moment can work out how based on 1 element, since can't have elements focused @ same time. essentially:
if button or button b or button c has been clicked toggle student picker button true
the related issue that, whilst have working 1 control, , toggle fires, moment put focus on control toggle switches off. don't want that. ideally, if toggle off when button gained focus, yes, should toggle off again. fi visible, should not toggle off.
ideally use multidatatrigger
found out conditions must true. here decided set of datatriggers:
<togglebutton x:name="buttonstudentpicker" content="student picker" horizontalalignment="right" margin="2,10,2,10" borderthickness="0,5,0,0" background="{x:null}"> <togglebutton.layouttransform> <rotatetransform angle="90"/> </togglebutton.layouttransform> <togglebutton.style> <style targettype="togglebutton"> <style.triggers> <datatrigger binding="{binding elementname=buttonbiblereadingmain, path=ispressed, mode=oneway}" value="true"> <setter property="ischecked" value="true"/> </datatrigger> <datatrigger binding="{binding elementname=buttonbiblereadingclass1, path=ispressed, mode=oneway}" value="true"> <setter property="ischecked" value="true"/> </datatrigger> <datatrigger binding="{binding elementname=buttonbiblereadingclass2, path=ispressed, mode=oneway}" value="true"> <setter property="ischecked" value="true"/> </datatrigger> </style.triggers> </style> </togglebutton.style> </togglebutton>
i thought try ispressed
see if works , not right property use.
i can't right. if click button, trigger toggle true. don't else.
clear mud?
update: if add click handler buttons. example:
<button name="buttonbiblereadingmain" grid.column="1" background="transparent" click="buttonbiblereadingmain_click"> <image source="images/assignmenttypebiblereading.png" margin="2"/> </button>
and put code-behind:
private void buttonbiblereadingmain_click(object sender, routedeventargs e) { buttonstudentpicker.ischecked = true; }
it want. button clicked, ensures panel visible. , panel stay visible long want. need each of controls want force panel display.
you can make multidatatrigger
working or instead of and, because of this:
(a , b) <=> ¬(¬a or ¬b)
applied code:
<multidatatrigger> <multidatatrigger.conditions> <condition binding="{binding elementname=buttonbiblereadingmain, path=ispressed, mode=oneway}" value="false" /> <condition binding="{binding elementname=buttonbiblereadingclass1, path=ispressed, mode=oneway}" value="false" /> <condition binding="{binding elementname=buttonbiblereadingclass2, path=ispressed, mode=oneway}" value="false" /> </multidatatrigger.conditions> <setter property="ischecked" value="false"/> </multidatatrigger>
so invert true values false, , set default value of tooglebutton.ischecked true. way, have toogle button unchecked if every button unpressed.
Comments
Post a Comment