Bind command to hub section header click in Windows 10 Universal App - mvvm

Suppose I got a hub page (HubPageView) and a couple of hub sections inside that page e.g.
<Hub Header="{Binding AppName}">
<HubSection IsHeaderInteractive="True"
Header="Section 1">
...
</HubSection>
...
</Hub>
When rendered the above shows as "Section 1 See more" and I take it that if the user taps "See more" the app is supposed to navigate to, say, Section1PageView.
I'm trying hard to follow the MVVM pattern so I'd like to bind the tap to a command (NavigateToSection1Command) instead of using the ItemClick event - how do I accomplish this?

The Hub class has a SectionHeaderClick event to which you could attach an EventTriggerBehavior and bind your Command to it.
<Page xmlns:i="using:Microsoft.Xaml.Interactivity"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
<Hub Header="{Binding AppName}">
<i:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="SectionHeaderClick">
<core:InvokeCommandAction Command="{Binding NavigateToSectionCommand}" />
</core:EventTriggerBehavior>
</i:Interaction.Behaviors>
</Hub>
</Page>
The SectionHeaderClick is the event that MS put for us to interact with the Hub Header, but the way it works will make MVVM's life harder. You see, that event passes the Section object that was clicked as an argument. You will lose that by attaching a command, as there is no built in way to pass an event argument to a command and there will be no way to tell which section the command was fired from.
That being said, I think that placing a Button or TextBlock at the HubSection's Header and attaching a EventTriggerBehavior to it`s Click event would better suit your needs.
Ps: You will have to add a Reference to the Behaviors SDK. Go to Add References > Universal Windows > Extensions, then check Behaviors SDK (XAML)

Related

dotnet maui how to hide the back button on desktop?

I'm trying to hide the backbutton shown in the image on desktop, but no matter what I tried, then it keept showing up.
I have tried
<Shell.BackButtonBehavior>
<BackButtonBehavior IsVisible="False" IsEnabled="False" />
</Shell.BackButtonBehavior>
And I have tried following this SO post Why Back Button is hidden in Maui?
My navigation is done by saying await Shell.Current.GoToAsync(new ShellNavigationState(location), false);
Am I missing something?
So everything you need to know can be found here:
https://learn.microsoft.com/en-us/dotnet/maui/user-interface/pages/navigationpage
NavigationPage.HasBackButton = true/false
Image (Proof)
https://gyazo.com/afbc744e7b6c5d1caa56960a536390c7
If this was helpful, mark this please as answer :)
This technique (the code in your question), added within the <ContentPage ... > declaration at the top of the xaml:
<Shell.BackButtonBehavior>
<BackButtonBehavior IsVisible="False" IsEnabled="False" />
</Shell.BackButtonBehavior>
seems to work when using the Shell to activate pages in C# codebehind (often in the BindingSource e.g., viewmodel):
await Shell.Current.GoToAsync($"{nameof(MyContentPage)}");
Adding this within the <ContentPage ...> declaration at the top of the xaml:
NavigationPage.HasBackButton="false"
seems to be applicable when using the push/pop within a NavigationPage:
await Navigation.PushAsync(new DetailsPage());
I don't use the Navigation.PushAsync. My app requires very specific navigation based on current data state, so a stack doesn't work for me.
I have verified setting the Shell.BackButtonBehavior (in the very code you provided) works in my case because I am activating pages via
await Shell.Current.GoToAsync
To enable/disable something you can use OnPlatform or OnIdiom
Exemple :
NavigationPage.HasBackButton="{OnIdiom Default='True', Desktop='False'}"

Custom-UI: Force Developer-Tab to be visible

I have a MS-Word template where the user sometimes will have to edit content controls.
Therefore I would like to force the developer tab to be visible whenever a document based on this template is opened.
I changed the CustomUI:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon>
<tabs>
<tab idMso="TabDeveloper" visible="true" />
</tabs>
</ribbon>
</customUI>
No error is thrown when the document is opened - but the Developer tab isn't visible.
Any thing else I have to consider, to force the tab to be visible?
(Vice versa works: hiding a visible Developer-Tab by setting visible to false)
(There is no VBA attached to the document.)
OK - sometimes a short break helps:
I am adding a custom tab containing the relevant buttons from the developer tab. Plus: renaming them :-)
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon>
<tabs>
<tab id="Abnahme" label="Abnahmedokument">
<group id="x" label="Eingabefelder">
<button idMso="ContentControlText" label="neues Eingabefeld" size="large"/>
<button idMso="ControlProperties" label="Eingabefeld bearbeiten" size="large"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
I know of no method other than user education.
You could, in your distribution template, add your own duplicate tab or a tab that has the controls for Content Controls. Better practice is probably to put the Content Control tools on your own additional tab and ignore the Developer Tab.
See also Hide/Show all tabs on Ribbon except Custom tabs which also says there is no method available via VBA.
The following caveat is for someone finding your question in a web search and thinking about using the Word.OfficeUI file and finding this question in a web search. It does not appear that you are doing that.
For customization distribution, the UI editor in Word is a very poor tool. It is intended for personal use.
The Word.OfficeUI file produced by Word will overwrite any user customizations including QAT customizations. Placing that on a user's computer is mean and dictatorial just like overwriting the Normal template. It is a bad practice.
For distribution, you should be editing the XML of a global template. Likewise, such a template is the best method of distributing other user interface customizations like macros and building blocks. The methods for doing this are explored in the book RibbonX: Customizing the Ribbon User Interface and on Greg Maxey's page: Customize the Office Ribbon: It doesn't take rocket science.

Windows Store App: Eliminates GridView styles and use only for hub page layout

I try to make a Windows Store App (Metro) hub page which has four different templates with GridView.
I referenced link in Creating hub page with different controls in Windows 8 page and it works fine.
But GridView has a default style which interacts with touch(and mouse) activity.
It grayed when hover, and shows click interaction.
My question is, how to disable those behaviors?
I tried to dig with Blend but hard to find the place to be customized.
Sorry I don't know MS Blend
But in visual studio please follow below instruction :
right click on your grid
go to Edit Additional Template
click on 'Edit Generated Item Container(ItemContainerStyle)' > 'Edit a Copy...'
go to XAML code and remove the PointerOver content from your code. the code should be like the following
//some code here
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="PointerOverPressed"/>
<VisualState x:Name="Disabled">
//continue

seam redirect page

I use seam to manage a viewer page.
In my page I have a div (iframe) where an html page is displayed on particular conditions.
In particular I need to change the page displayed in this div deciding from serverside.
I try to explain me better:
on commandButton click the control is passed to server (using an action). This action method set some things and know what page should be loaded after (or none in some cases).
when the control come back to the caller page, the new page setted by the action method must be called (it uses the things specified by the action method).
How can I do this?
NOTE: the oncomplete tag is not usable in this context because I have many commandButton and it is called everytime I click on one of the commandButtons.
I'm not completely sure what your trying to do.
Are these pages rendered dynamically?
You can generate HTML from the serversite and just output it using a <h:outputText id="iframediv" value="#{controller.htmlparameter}" escape="false" />
An <a4j:commandButton reRender="iframediv"> could then reRender this dynamically generated page.
If the pages are defined statically you could include them like this.
<rich:panel id="iframediv">
<a4j:outputPanel rendered="{controller.page1}">
<ui:include src="page1.xhtml" />
</a4j:outputPanel>
<a4j:outputPanel rendered="{controller.page2}">
<ui:include src="page2.xhtml" />
</a4j:outputPanel>
</rich:panel>
The controller's page1 and page2 parameters should be booleans and set by the action you've called.
Solved using javascript activated only when a particular property is present over the serverside.

How do you contribute a command to an editor context menu in Eclipse

I want to contribute a command to the context menu of any text editor when text is selected. In "the old days", I would have done this using objectContribution and a nested action with "enablesFor='+'".
How does one do this using commands instead of actions?
If I revisit my answer "Eclipse RCP: Actions VS Commands", you need a Command handler.
This thread seems to sum up your options:
One is a common pattern, to instantiate the handler in the view itself and have the handler simply look at the view selection and control its own enabled state.
The handler API allows it to fire an event on enabled change, see org.eclipse.core.commands.AbstractHandler.
The other is to create a property tester that can get your view selection.
IWorkbenchPart p = page.findViewReference("your.id").getPart(false);
if (p!=null) {
p.getSite().getSelectionProvider().getSelection() ... whatever
}
Your view would monitor its own selection change events, and call org.eclipse.ui.services.IEvaluationService.requestEvaluation(String) (source here) for that property (which would cause all core expressions using that property tester to be re-evaluated).
The important point is that simply changing views would not cause a re-evaluation (and not change enabled state).
You can set up the property tester to be specific to each view that you need this for, or create one com.example.views.localSelection and use args to specify the view id.
I read more about the variables available in command expressions, and I came close to figuring it out on my own, but failed. I then asked a similar question on the eclipse newsgroup and was led in the right direction. Here's an example of how to do mostly what I was looking for:
<command
commandId="org.marcesher.blogcodeformatter.commands.wikiFormatterCommand"
tooltip="Format And Copy to Clipboard"
id="org.marcesher.blogcodeformatter.popup.wikiFormatterCommand">
<visibleWhen>
<with variable="selection">
<instanceof value="org.eclipse.jface.text.ITextSelection"/>
</with>
</visibleWhen>