UWP Template10 Hide FontIcon element when the menu "IsOpen" - binding

I have the following xaml construct.
<Controls:HamburgerMenu x:Name="MyHamburgerMenu">
<Controls:HamburgerMenu.PrimaryButtons>
<Controls:HamburgerButtonInfo x:Name="searchButton">
<FontIcon x:Name="searchButtonIcon" Width="48"
Height="48"
Glyph=""
Visibility="{Binding IsOpen, ???"/>
<AutoSuggestBox PlaceholderText="Search" QueryIcon="Find"/>
<Controls:HamburgerButtonInfo x:Name="searchButton">
</Controls:HamburgerMenu.PrimaryButtons>
</Controls:HamburgerMenu>
When the menu "IsOpen", the FontIcon element should be collapsed. If the menu not "IsOpen", the FontIcon element should be visible.
The groove music app has such a behaviour (see image in groove music app with opened menu).
Which are the parameters for the binding? An explanation for hiding the hamburger button is described in UWP Template10 Hide hamburger button when menu is open.
I guess that it's a template10 behaviour. I tried the following within the template10's Shell.xaml page.
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock x:Name="txt-1" Text="{Binding IsOpen, ElementName=MyHamburgerMenu}" Grid.Row="0"/>
<Controls:HamburgerMenu x:Name="MyHamburgerMenu" Grid.Row="1">
<Controls:HamburgerMenu.PrimaryButtons>
<Controls:HamburgerButtonInfo>
<TextBlock x:Name="txt-2" Text="{Binding IsOpen, ElementName=MyHamburgerMenu}"/>
</Controls:HamburgerButtonInfo>
</Controls:HamburgerMenu.PrimaryButtons>
</Controls:HamburgerMenu>
</Grid>
The TextBlock txt-1 displays the correct state of the HamburgerMenu's IsOpen property whereas the TextBlock txt-2 is empty.

You could use an IValueConverter to convert the IsOpen to a visibility
public class BooleanToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
return (!(bool)value) ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
return value;
}
}
This article explains IValueConverters and how to use them in your XAML
https://learn.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.Data.IValueConverter

So it works.
Change the binding to x:bind and reference it to "MyHamburgerMenu".
<Controls:HamburgerMenu x:Name="MyHamburgerMenu">
<Controls:HamburgerMenu.PrimaryButtons>
<Controls:HamburgerButtonInfo x:Name="searchButton">
<SymbolIcon Width="48"
Height="48"
Symbol="Find"
Visibility="{x:Bind MyHamburgerMenu.IsOpen, Mode=TwoWay, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=false}"/>
<AutoSuggestBox PlaceholderText="Search" QueryIcon="Find"/>
</Controls:HamburgerButtonInfo>
</Controls:HamburgerMenu.PrimaryButtons>
</Controls:HamburgerMenu>
and use a invertable BooleanToVisibilityConverter like that

Related

hide cancel and navitation in webview embbed B2C

I am doing an authentication in xamarin forms, using b2c, they asked me to embed the pop-up screen that triggers and in turn hide or eliminate both the cancel and the navigation bar, has someone done that part or otherwise modify it? (thanks in advance)enter image description here
Please check if below references can be worked in your case:
Hide Cancel button :
In custom policy:
Configure the setting.showCancelButton metadata item to false in the custom policy technical profile of the sign in or sign up or page for it is requiredrequired.
Example:
<TechnicalProfile Id="LocalAccountSignUpWithLogonEmail">
<DisplayName>Email signup</DisplayName>
<Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.SelfAssertedAttributeProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<Metadata>
<Item Key="IpAddressClaimReferenceId">IpAddress</Item>
<Item Key="ContentDefinitionReferenceId">api.localaccountsignup</Item>
<Item Key="language.button_continue">Create</Item>
<Item Key=" setting.showCancelButton ">false</Item>
</Metadata>
<InputClaims>….
….
</TechnicalProfile>
See self asserted technical profile reference & Microsoft Q&A Reference
Through Xamarin Form:
For Xamarin forms ,Use Xamarin.Forms renderer to hide the "Cancel" button of a SearchBar on iOS using Control.ShowsCancelButton = false;
protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == "Text")
{ Control.ShowsCancelButton = false;}
}
References:
Xamarin forms– iOS disable cancel button on SearchBar (weblogs.us)
How to handle/cancel back navigation in Xamarin Forms-Stack Overflow
Disable Navigation bar:
If you use webview in the NavigationPage or NavigationPage wrap the contentpage, Try to add NavigationPage.HasNavigationBar="False" into your contentPage tags like following xaml, to disable navigation bar.
Example:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:FormsWebViewTest"
x:Class="FormsWebViewTest.MainPage"
NavigationPage.HasNavigationBar="False">
...........
.......//other part
</ContentPage>
Or
SetHasNavigationBar to false on your navigation page (in content page constructor).
ex:
public MyPage()
{
InitializeComponent();
NavigationPage.SetHasNavigationBar(this, false);
}

ZK: Custom Component with Listbox not binding SelectedItem

I am working on creating a new Custom Component and unable to bind a controller's property to the SelectedItem annotation property of my custom component. My idea is that any one who passes my Custom component SelectedItem annotation, I should be able to retrieve it in my component and assign it myself to the ListBox's SelectedItem property. This will give flexibility to the users of my component to not worry about the internals and the component will be re-usable.
Problem is that I am not able to get/set the Controller value in my custom component. I get NULL. Can someone please help me resolve this issue or point me to the right direction? Here is the code:
<bandbox id="filterDropdownBandBox" instant="true" readonly="false">
<bandpopup id="filterDropdownBandPopup" style="max-height:250px;overflow-x:hidden">
<listbox id="listBox" hflex="1" rows="0" >
<template name="model">
<listitem>
<listcell label="${each.label}" />
</listitem>
</template>
</listbox>
</bandpopup>
public class FilterDropdown extends Div implements IdSpace {
#Wire
private Listbox listBox;
#Wire
private Bandpopup filterDropdownBandPopup;
#Wire
private Bandbox filterDropdownBandBox;
private ListModelList<GenericNameValuePair> lbModel;
public FilterDropdown() {
Executions.createComponents("/filterDropdown.zul", this, null);
Selectors.wireComponents(this, this, false);
Selectors.wireEventListeners(this, this);
}
public void setSelectedItem(Listitem l) // getting NULL here
{
l.setParent(listBox);
listBox.setSelectedItem(l);
}
public void saveSelection() {
listBox.getSelectedItem();
}
public Listitem getSelectedItem() {
return listBox.getSelectedItem();
}
}
This is how I added this component to lang-addon.xml file
<component>
<component-name>filter-dropdown</component-name>
<extends>div</extends>
<component-class>com.components.FilterDropdown</component-class>
<annotation>
<annotation-name>DDBIND</annotation-name>
<property-name>selectedItem</property-name>
<attribute>
<attribute-name>ACCESS</attribute-name>
<attribute-value>both</attribute-value>
</attribute>
</annotation>
</component>
And this is how I am using my custom component in other ZUL files
<filter-dropdown id="filterProjDropdown" selectedItem="#DDBIND{XYZCtrl.bean.propbean.actualProp}"/>
First of all, keep to the normal annotation like #load(), #save() or #bind()`.
Now, mine first suggestion is to throw your zul away.
Implement the AfterCompose interface in your component and add all the items there with a renderer.
It makes it easier for anyone to change that component and it will be more performent.
Secondly, use the correct annotation in your class :
#ComponentAnnotation({"selectedItem:#ZKBIND(ACCESS=both,SAVE_EVENT=onSelect)"})
Like this your lang-addon.xml should look like :
<component>
<component-name>filter-dropdown</component-name>
<extends>div</extends>
<component-class>com.components.FilterDropdown</component-class>
</component>
And as last :
You need to inform the binder that there was a change in the selectedItems :
Events.postEvent("onSelect", FilterDropdown.this, selectedItems);
You should handle this in an eventlistener attached to the bandbox.
If you want an advanced working component code including in how to export it to a separate jar, please check out mine github project.

ImageView in ListView briefly shows previous image on scroll with RecycleElement enabled

I have a list of the following class:
public class Set {
public string IconUrl { get; set; }
}
This list is bound to a ListView:
<ListView ItemsSource="{Binding Sets}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<Image Source="{Binding IconUrl}" />
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
When the view loads and the user starts scrolling, the cells are reused and the Image briefly shows the previous image before the new image is downloaded and rendered.
Is there a way to prevent this kind of behavior without disabling RecycleElement?
I haven't tried this but on ViewCell you have Disappearing and Appearing events that you can hook into.
You may want to look at releasing the image source on the Disappearing event handler, but sometimes this can occur sometime later I think from recollection, so you may also want to try releasing the image on the Appearing event handler that hopefully will be executed prior to the display on the screen?
We have solved this by manually setting the Image source to null to force the render of the new images. we achieve this by using OnBindingContextChanged Event of the ListView. Hope this helps.
Edited (Added code below):
We have something like this:
public class PeopleCell : ViewCell
{...
Image profileImage;
public PeopleCell()
{
profileImage = new Image
{
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand,
BackgroundColor = Color.FromHex("f5f5f5"),
Source = ImageSource.FromFile("profile_blankimage"),
};...
protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();
people = BindingContext as CustomerViewModel;
if(people.Customer.Avatar != null)
profileImage.Source = ImageSource.FromUri(new Uri(people.Customer.Avatar.Url));

Keep current tab when updating tabview

I'm using primefaces 4.0 and have a tabview with 4 tabs. When I click a button in one of the tabs I want to update all of the tabs but keep the current tab selected. However, when I update the tabview, the selected tab keeps getting set back to the first tab.
Is there a simple way to keep the current tab when updating the entire tabview?
You could use activeIndex attribut from tabView :
<p:tabView activeIndex="#{bean.activeIndex}"/>
From Primeface User Guide:
activeIndex is an Integer with default value 0. Index of the active tab.
In addition to the other answer there is one more thing: the activeIndex is actually a client-side index. That means that if you have unrendered tabs then you would have to compensate, so the unrendered tabs wouldn't count towards the index number. You can do it like this:
String targetTabClientId = "my_tabview:my_tab";
Tab targetTab = (Tab) FacesContext.getCurrentInstance().getViewRoot().findComponent(targetTabClientId);
TabView tabView = (TabView) targetTab.getParent();
int clientActiveIndex = 0;
for (UIComponent tab : tabView.getChildren()) {
if (tab.equals(targetTab))
break;
if (tab.isRendered())
++clientActiveIndex;
}
return clientActiveIndex;
You could on tab change store the tab index as a global JavaScript variable.
<script>
var activeIndex = 0;
function handleTabChange(event, index) {
activeIndex = index;
}
</script>
...
<p:tabView widgetVar="tabView1" onTabChange="handleTabChange(event, index)">
...
</p:tabView>
You could then on complete of a command restore the tab index from global JavaScript variable.
<p:commandButton ... oncomplete="tabView1.select(activeIndex)" />
This simple solution works for me.
this is my tab list which is like a header, maintained across all pages:
<h:form id="menuForm">
<p:tabMenu activeIndex="#{param.i}" >
<p:menuitem value="Admin" outcome="/administration/index.xhtml?i=0" >
<f:param name="i" value="0"/>
</p:menuitem>
<p:menuitem value="Marketing" outcome="/marketing/index.xhtml?i=1" >
<f:param name="i" value="1"/>
</p:menuitem>
...
</p:tabMenu>
</h:form>
And then, if I have a button that directs me to another page, my button looks like this:
<p:button outcome="/edit-user.xhtml?i=2" value="Edit User" />
You can see demo here: http://www.primefaces.org/showcase/ui/menu/tabMenu.xhtml?i=0

mouseover actionscript

I am designing a page in flex and I have a one image. Specific text should be shown when user hovers mouse to the image. Here is my actionScript code that I wrote but it is not working (it is not showing text on mouseOver event:(
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="100" minHeight="100">
<fx:Script>
private var helpText:String = "Some Text."
private function helpIconEvent(e:MouseEvent):void{
if(e.type == "mouseOver"){
e.currentTarget.helpText.visible = true;
}
}
private function addEventToHelpIcon():void {
helpIcon.addEventListener(MouseEvent.MOUSE_OVER, helpIconEvent);
}
</fx:Script>
<mx:Image id="helpIcon" x="270" y="187" width="50" height="50" mouseOver="addEventToHelpIcon"
source="source_path"/>
Any help/insight will be highly appreciated.
Thanks.
There are several issues:
You are not adding the mouse over listener correctly. You are actually adding two event listeners, one in MXML and then when that event happens you add the second one. Just use the MXML listener (see below).
In function that runs when the mouse over happens, you are trying to set the visible property on a String object. A String by itself will not display anything. You can display the String with a Label object, in a tool-tip, or some other GUI object. You need to figure out the right GUI object to use and pass the text to that object.
Here's a very simple example:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="100" minHeight="100">
<fx:Script>
private function onMouseOver():void {
helpLabel.visible=true;
}
private function onMouseOut():void {
helpLabel.visible=false;
}
</fx:Script>
<s:Image id="helpIcon" x="270" y="187"
width="50" height="50"
mouseOver="onMouseOver()" mouseOut="onMouseOut()"
source="source_path"/>
<!-- note the mouse event handlers are so simple in this case, you can also do them in line -->
<s:Image id="alternateMethod" mouseOver="helpLabel.visible=true;"
mouseOut="helpLabel.visible=false;" />
<s:Label id="helpLabel" x="100" y="100" visible="false" text="Some Text."/>
</s:Application>
It think your code should be more like this, but I'm not used to flex so bear with me if I'm wrong.
private function foo(e:MouseEvent):void {
if(e.type == MouseEvent.ROLL_OVER)
//Do stuff...
}

Resources