I'm learning the new Wix Code online development IDE and want to understand how to control the visibility of an item on mobile or desktop. How should I approach this?
If you're just trying to hide things from mobile, there's an easier way to do it (go to the mobile editor and click the element's hide button).
But assuming you're asking about WixCode because you need custom behavior:
Check out the formFactor API
https://www.wix.com/code/reference/wix-window.html#formFactor
And the properties panel
https://support.wix.com/en/article/working-with-the-properties-panel-6441151
The properties panel is where you'll set the element's default visibility.
Then check the formFactor using that API above
And finally use $w('#elementname).show() or hide() to change its visibility.
You have two options -
If you only want to control what appears on mobile vs desktop, you have a toggle to hide elements on mobile.
If you want to change dynamically visibility of elements on each or both, use the formFactor and hide/show/collapse/expand APIs.
For instance, on a button click you may want to show element1 on desktop and element 2 on mobile. The code will look something like the following -
import wixWindow from 'wix-window';
export function button1_onClick() {
if (wixWindow.formFactor === 'Mobile') {
$w('#element2').show();
}
else {
$w('#element1').show();
}
}
Related
I need to do a master detail layout page in Xamarin which then will be used in child pages.
Please check the screenshot below:
I need to have a header part with button for notifications and a button for context menu plus a header.
What is the best approach how I can create this layout in Xamarin?
I will assume that you want to use Xamarin.Forms, instead of using Xamarin.Android and Xamarin.iOS separately.
One approach would be to use default MasterDetailPage as described here or even better to try it with Shell as described here.
Then, you would need to create your CustomNavigationPage and write a custom renderer for it.
Second approach would be to do some tricks, again creating your CustomNavigationPage with template(so that the navigation bar is always displayed) and that you change content dynamically.
Also, you would need to hide default navigation bar and attach click events to your menu button to really open up the menu.
Hope you got it clearly.
MasterDetailPage already provides nearly all functionality that you have asked for, so in some way your question isn't quite clear as you already mention MasterDetailPage. The only remaining problem I can see is how to set up a custom header, and that is than with NavigationPage.TitleView.
Xamarin Forms navigation examples I see leverage a NavigationPage...
public App()
{
InitializeComponent();
MainPage = new NavigationPage(new HyperTrack2.Login());
}
and then when an event occurs to move to the next page...
async void OnLogin(object sender, EventArgs e)
{
await Navigation.PushAsync(new MapPage());
}
How can one show a view without using the NavigationPage?
Depends on what you consider a view to be.
The process you outlined in your question is the prefered way to navigate using Xamarin pages. Xamarin pages contain one or more controls, or views. Usually some layout views at the root and then they branch out as needed.
The built in navigation mechanism actually utilises the optimal native techniques for navigating inside your application and will allow you to use standard gestures and buttons for navigations, display standard toolbars and title views, etc.
I fully recommend that unless you have very specific needs, you keep using the built in navigation mechanism.
Otherwise, your other option for moving through xamarin.forms pages is by just settting the MainPage property of your Application class (called App by default)
You can either access it through Application.Current.MainPage = new MyPage(); or if writing code within the app class, directly by calling MainPage = new MyPage();
Lastly, you specifically mention showing a view and not a page. If you are talking about a single control within a page, you can either bind it's IsVisible property to some value in your ViewModel, or you can give it an x:Name="myControl" (if using XAML) or store a reference to it (if creating UI in code behind) and then do myControl.IsVisible = true/false somewhere in your code behind. This toggles the visibility of a single control, which will then become a part of your page hiearchy.
If you instead wish to display the view as a "popup" over the existing page, without it actually becoming a part of the page, there are some built in simple UI elements you can use, such as action sheet and display alert. These provide simple popup windows that offer a couple of actions or display a message.
For more complex UI, look into Nuget plugin packages, or if you prefer, you can write your own by implementing the functionality on all the target platforms you require.
I suggest looking into Acr User dialogs as it's a wonderful plugin that has served me quite well. It has a much broader set of UI elements you can use, but it still won't let you define any element that you want and display it in a popup, to do that, search for popup plugins for Xamarin.Forms. There are quite a few, but none work perfectly imho.
I created a prototype for my application. To make the application looks better, I decided to remove the scrollbar. Does anybody know how to make it?
There is two ways (see screenshot, numbers "1" and "2"). Go to region properties, User Interface tab:
(updated) Choose template Alert and set property Alert Icons - Hide Icons to hide alert icon.
or
In Standard template, choose Body Overflow - Hide (as far as I remember, this option present only in Oracle APEX 5.0 and higher)
Hopefully changing the css style helps:
.a-GV-w-scroll {
overflow: hidden!important;
}
See the "inline-css" on this page.
how can i find the specific button on design mode where i have several buttons ie: hundered of buttons so that they all like spaghetti and one button may be under another button or a groupbox (i might be playing with the visibilities ) and i want to see my button number 83 on the design. how can i see him? where is he hiding? :) i use visual studio as an IDE. thanks.
MessageBox.Show(" where is the specific button? i know that he is somewhere on the form but cant distinguish it on the design since its somewhere under something i cant find it");
Use Document Outline (View - Other Windows - Document Outline)
Just pick the button from the tree and voila.
PS: this works for other types of designers (WPF/Silverlight, ASP.NET)
You can access it via the Properties Window. There is a drop-down that will list all of the items in your form in design mode.
Then use the drop-down. The drop-down will list all of the items on your form so you will scroll through the list to find Button number 83.
Images were pulled from MS Visual Studio: The properties Window which contains an explanation of the window.
Have you tried using the properties window?
I am developing a Firefox addon which will be primarily a toolbar but will have some dialog/windows for things like preferences.
In browser.xul I declare my global variable which I will store all variables within:
var coolAddon = {};
Then in my toolbar I want to be able to call methods of coolAddon, for example on button clicks.
If I open a dialog from browser.xul, in the dialog I can access coolAddon using window.opener.coolAddon, which works well. The problem is this does not work on the toolbar - only on windows/dialogs. What happens in the toolbar is window.opener is null/undefined.
How can I access coolAddon that is declared in browser.xul, from within the toolbar? I don't want to redeclare it because I need to keep it's current property values (I realise my example does not currently have any properties or methods).
You should be able to access coolAddon directly from your toolbar. It is in the browser context.
Window.opener is only needed when you are in a completely different window.