Dotnet Maui MenuFlyout , how to bind to Collection - maui

There is no ItemsSource property on the dotnet maui 7 ContextMenu MenuFlyout. How can we bind this to a collection. Surely they don't expect us to hardcode this? I'm trying to get a list of these within a MenuFlyoutSubItem
https://learn.microsoft.com/en-us/dotnet/maui/user-interface/context-menu?view=net-maui-7.0
Thanks

Anyway we found a workaround, as we needed a dynamically generated context menu, we now use a TapGestureRecogniser to handle a right click event and then in the code behind create the whole context menu itself each time and attach it to the view.
void ContextMenu_Selected(System.Object sender,Microsoft.Maui.Controls.TappedEventArgs e)
{
HorizontalStackLayout hs = (HorizontalStackLayout)sender;
MenuFlyout mf = new MenuFlyout();
MenuFlyoutItem flyoutItem = new MenuFlyoutItem();
flyoutItem.Text = "Menu text"
mf.Add(flyoutItem);
FlyoutBase.SetContextFlyout(hs, mf);
}

Related

Syncfusion Diagram nodes custom properties

In EJ2 .NET Core Syncfusion Diagram component how can I extend the Node object with custom properties and save them into database. The documentation describes only the saving / loading of the whole diagram. Ideally, I would like upon each node selection the custom properties, coming from datatable, to be shown in the right pane as in angular diagram builder example. Is there any event which will notify about user selection?
We can extend the node object with custom properties by using addInfo property. Please find below code example for how to use addInfo property of node.
Dictionary<string, object> addInfo = new Dictionary<string, object>();
addInfo.Add("Text", "New");
Nodes.Add(new DiagramNode()
{
Id = "NewIdea",
OffsetY = 80,
OffsetX = 340,
Height = 60,
AddInfo =addInfo,
Shape = new { type = "Flow", shape = "Terminator" }
});
The selection change event gets fired, while selecting the node. In that event, the args.newValue parameter assist to identify which node is get selected. Please find below code example for how to use the selectionChange event.
<ejs-diagram id="container" width="100%" height="700px" selectionChange="selectionChange" nodes="ViewBag.nodes" connectors="ViewBag.connectors">
<e-diagram-snapsettings horizontalGridlines="ViewBag.gridLines" verticalGridlines="ViewBag.gridLines"></e-diagram-snapsettings>
</ejs-diagram>
function selectionChange(args) {
var node = args.newValue[0];
// define your logic here
}
For more information about selectionChange event, please refer to below help documentation link
Documentation: https://ej2.syncfusion.com/documentation/api/diagram/iSelectionChangeEventArgs/
Regards,
Ramya T

Control Wicket wizard's flow by setting setComplete(boolean)

Hey there I'm still trying to improve a customized Wicket Wizard to display the steps with following states: active, completed, pending. Therefore the information of isCompleted(); should return the right value. Refering to a previous question, isComplete(); returns true, if the wizard can go to the next step.
How can I manipulate this information to get the full advantage of my draft? E.g. in one WizardStep I have multiple input fields.
super(new ResourceModel("daten.title"), new ResourceModel("daten.summary"));
java.util.Collections.addAll(sprachen, "Deutsch","English","Français","Italiano");
add(name = new RequiredTextField<String>("name", Model.of("")));
add(vorname = new RequiredTextField<String>("vorname", Model.of("")));
add(strasse = new RequiredTextField<String>("strasse", Model.of("")));
add(ort = new RequiredTextField<String>("ort", Model.of("")));
...
I don't want the step to "be completed" until each field is filled out. To check the condition I'd have to add an AjaxListener to each component and check for it's state to setComplete(boolean);. Can I control this flow from outside the wizard form? For example with an implementation of ICondition or is there another way? Because basically I can't go to the next step, because all of my textfields are RequiredTextField and cannot be skipped.
Any suggestions are highly appreciated.
Update / Solution
Component buttonbar = getForm().get(Wizard.BUTTONS_ID);
buttonbar.setOutputMarkupId(true);
Just get(Wizard.BUTTONS_ID); won't work.
Thanks to Sven Meier for the hint!
You'll have to add an AjaxFormComponentUpdatingBehavior to all your form components.
Then override #onEvent() in your wizard:
public MyWizard(id, WizardModel model) {
super(id, model);
get(Wizard.BUTTONS_ID).setOutputMarkupId(true);
}
public void onEvent(IEvent<?> event) {
if (event.getPayload() instanceof AjaxRequestTarget) {
((AjaxRequestTarget)event.getPayload()).add(get(Wizard.BUTTONS_ID));
}
}
Let your step#isComplete() return true depending on its model values, this way the wizard buttons will always be up to date.

Menu or MenuButton with separate click handler

I'm looking for a widget like this.
http://ppt.cc/RPfL
Clicking "View" and triangle (drop down icon) need to perform two different functions.
Clicking the triangle opening the menu.
I tried creating 2 buttons to emulate, but the 2 buttons have extra space in between them.
How can I eliminate the space between buttons or, is there a convenient way to accomplish this?
thank you all!!
An IconMenuButton (which is a sub class of IconButton) will provide what you need.
Menu menu = new Menu();
MenuItem newItem = new MenuItem("New");
MenuItem openItem = new MenuItem("Open");
MenuItem saveItem = new MenuItem("Save");
MenuItem saveAsItem = new MenuItem("Save As");
menu.setItems(newItem, openItem, saveItem, saveAsItem);
IconMenuButton menuButton = new IconMenuButton("View", menu);
Also check SmartGWT samples I've given in my comment and RibbonBar sample.

DevExpress RibbonPage added programatically does not show

I've a RibbonControl in a mdiform and another RibbonControl added at design time in a MDIChildForm. Then in runtime, I add a RibbonPage, with a RibbonGroup and a BarButtonItem. Like this:
private void MDIChildForm_Load(object sender, EventArgs e) {
BarButtonItem btn = ribbonControl1.Items.CreateButton("Test Button");
RibbonPageGroup group1 = new RibbonPageGroup("Test Group");
group1.ItemLinks.Add(btn);
RibbonPage page1 = new RibbonPage("Test Page");
page1.Groups.Add(group1);
ribbonControl1.Pages.Add(page1);
}
The "Test Page" isn't visible in the MdiParent. But, when I change the active mdi child form, and the ribbon do the merge, the page appears!
It looks like the page isn't merged until I change the active mdi child form.
Am I missing something?
I've found a solution, but I think is not the most elegant way to solve it:
mainRibbon.UnMergeRibbon();
mainRibbon.MergeRibbon(mdiChildForm.ChildRibbon);
A public property to access the child Ribbon was needed.

How to Get ViewModel From SelectedTab in ZK?

I have a toolBar where i am using plenty of item now when i am clicking on any item i am creating a tab.Something like this code
public static void openNewTab(String title, String path, Tabbox mainTab) {
Tab tab = new Tab(title);
tab.setClosable(true);
tab.setParent(mainTab.getTabs());
Tabpanel tabpanel = new Tabpanel();
Include include = new Include(path);
include.setParent(tabpanel);
tabpanel.setParent(mainTab.getTabpanels());
mainTab.setSelectedTab(tab);
}
Now i will want to get the ViewModel of selected tab When any Ctrl Key press in ZUL...
I have this
#Wire("#mainTab")
Tabbox mainTab;
Tab tab = mainTab.getSelectedTab( );
Can it possible to get ViewModel from the selectedTab varaibles?
And i am doing like this
Include include = new Include(path);
include.setParent(tabpanel);
Object object = include.getAttribute("viewModel");
Now object is giving null Can we get ViewModel from here while i am including a ZUl here?
It seems the id is the attribute name to get vm, see sample at zkfiddle
Btw "binder" is the attribute name to get binder, for more information please refer to Source code of binder
You can also try to use Component.getAttributes to get the attribute map and check all attributes in it, see Javadoc: Component#getAttributes