c# - How use ContextFlyout in a StackPanel in UWP? -


in gridview, trying show context menu when user right clicks item.

i tried:

 <gridview.itemtemplate>     <datatemplate>        <stackpanel orientation="vertical" width="120" background="lightblue">        <stackpanel.contextflyout>              <menuflyout>                   <menuflyoutitem text="change color" click="changecoloritem_click" />              </menuflyout> ... 

but stackpanel.contextflyout throws error. missing?

update

the error is: the attachable property 'contextflyout' not found in type 'stackpanel'

contextflyout property of uielement, , stackpanel derived uielement.

contextflyout property of uielement, , stackpanel derived uielement.

yes right, careful contextflyout property available since introduced version 3.0, version 10.0.14393.0. need check api contract version , device family version.

for api contract version 1.0/2.0, @igor damiani suggested, can use flyoutbase.attachedflyout, , can datacontext example in righttapped event of stackpanel:

private void stackpanel_righttapped(object sender, righttappedroutedeventargs e) {     flyoutbase.showattachedflyout(sender stackpanel);     var datacontext = ((frameworkelement)e.originalsource).datacontext; } 

but noticed menuflyoutitem possible color changing, need access uielements inside stackpanel or stackpanel itself. if so, it's better bind color property implemented inotifypropertychanged interface.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -