c# - Hyperlink - content binding -
i have textbox user inputs uri. becomes navigateuri property of hyperlink, allowing user click on link open page.
<!-- input textbox --> <textbox x:name="linkbox" width="175" text="{binding path=docref, mode=twoway}" /> <!-- hyperlink --> <textblock> <hyperlink datacontext="{binding elementname=linkbox}" navigateuri="{binding path=text}" requestnavigate="hyperlink_requestnavigate"> <textblock datacontext="{binding elementname=linkbox}" text="{binding path=text}" /> </hyperlink> </textblock>
this works inputting whole (absolute) uri in textbox. however, user wants input 'document.extn' bit of uri, , have application prepend rest of resource (ie, 'http://www.example.com/' bit). how set base part of uri , append document reference (preferably in xaml)? came across hyperlink's baseuri property sounds perfect, unfortunately protected, doesn't work:
<hyperlink datacontext="{binding elementname=linkbox}" baseuri="http://www.example.com/" navigateuri="{binding path=text}" requestnavigate="hyperlink_requestnavigate">
can assist?
you may able use multibinding
join 2 strings need
<hyperlink datacontext="{binding elementname=linkbox}" requestnavigate="hyperlink_requestnavigate"> <hyperlink.navigateuri> <multibinding stringformat="{}{0}{1}"> <binding fallbackvalue="http://www.example.com/" /> <binding path="text" /> </multibinding> </hyperlink.navigateuri> </hyperlink>
Comments
Post a Comment