How to make a CommandBar persistent in WinRT? - winrt-xaml

I saw this article on the code project, where the author mentions the possibility of making an ApplicationBar persistent.
I want my app bar always visible!
You can make the app bars display at all times by setting the IsPersistent property to True.
I'd like to do the same in my Windows 8.1 (WinRT) project. I can't see a IsPersistent property for the CommandBar class here.

It's not IsPersistant, it's IsSticky

Using the CommandBar within the Page.Bottom[Top]AppBar areas will not give you this ability. As presently defined, AppBars are transient and can always be dismissed by the user. IsOpen/IsSticky are ways to help it stay open longer, but the user can always still dismiss them.
If you want a persistent 'appbar' feel that isn't dismissable, you'll want to just create something that stays bottom-aligned on your view. You will however, be having different behavior than the user may expect given other apps.

You can always use Closed Method of the CommandBar.
And set within the method IsOpen to True.
This way to force the CommandBar to always be visible even if the user press Windows+Z, Right click, etc.

Related

How to make backbutton work for a control, not just Page in UWP?

I followed this link http://www.wintellect.com/devcenter/jprosise/handling-the-back-button-in-windows-10-uwp-apps and "successfully" make my button work. I mean I can make my backbutton work between pages. However, if I navigate to a control which is inside this page and will cover the whole screen, then it would not allow me to back to the page. I will stuck in that control.
I'm wondering how to solve this problem. Currently I can think two possible ways (0) Override OnBackRequested() inside the control's code behind or viewmodel? (1) Override OnHardwareButtonsBackPressed() inside the control's code behind or viewmodel?. I don't know if these are correct way to do it or there is some better way to do it. Another reason for me to override is that I need to make some changes to the page navigation behavior.
As you have guessed, you simply need to hide the control again when the back button is pressed or back is requested in some other way. I would listen for the BackRequested event (not the HardwareButtons.BackPressed event) in the page's code-behind, and in the handling method you can check to see if the control is currently shown. The reason I recommend the BackRequested event is because it is universal, while HardwareButtons.BackPressed only works on a phone. Anyway, if the control is visible, then hide it, and set the Handled property of the event arguments to true. If the control is already hidden, don't do anything special to handle the event (because in that case you will want the navigation system to handle it by navigating to the previous page, if there is one). There are many aspects to navigation in Windows 10 -- please see these pages on Navigation and the SystemNavigationManager.

How to get a callback when a View becomes visible on the screen on Android

Is there a way to get a callback when a View appears/disappears on the screen?
I need this for analytics purposes - eg. I need to check how many times people saw a view versus how many times they clicked on it.
I can tell whether a view is on screen at a certain point in time but I'm wondering whether there is a callback for that.
Also note that I'm not interested when a View's state becomes VISIBLE and not even when a view gets rendered (because eg. in a ViewPager the Views of the second page are rendered before they actually appear on screen).
We did several workarounds for certain scenarios but I'd like to have something which is more generic. We need it in ListViews, GridViews, ScrollViews and ViewPagers and each one of them presents different challenges.
Does ViewTreeObserver.OnGlobalLayoutListener help? I have never used it myself though.
See: http://developer.android.com/reference/android/view/ViewTreeObserver.OnGlobalLayoutListener.html

MdiParent property of child forms

I'm trying to do some practices on a MDI application in Microsoft Visual Studio 2012 but it seems that I'm doing something wrong.
I made a new Windows Forms Application project and changed the IsMdiContainer property of the first form to True. Then I add a new form by right clicking the project in solution explorer and selecting Add - New Item - Windows Form.
I'm trying to set MdiParent property of form2 to the MDI Container form, but it seems that form2 has no MdiParent property.
Here's the properties of form2 sorted alphabetically.
Of course I can open form2 as a child form this way:
form2 newMDIChild = new form2();
newMDIChild.MdiParent = this;
newMDIChild.Show();
I just wondered why the forms has no MDIParent property.
According to this page the child forms have a MdiParent property.
Any kind of help is much appreciated.
You're doing it right, instantiating the new form and assigning MdiParent there. Really there IS such a property, and in your code you're using it:
newMDIChild.MdiParent = this;
This is perfectly fine and the normal way of doing it.
Now, what you're pointing is that the designer doesn't shows it, which is also true. That don't means that the property don't exist (it does, and you're using it in fact!). Why it isn't in the designer property sheet is another history, totally irrelevant, but I suppose that it has to do with the fact that it's difficult, if not impossible to properly set MdiParent at design time. If you think about it, it must contain an instance of another form (with it's IsMdiContainer set to true). At design time, you don't have any instances of anything, as they're created as your program runs. There is no way that you can set it beforehand, as you must normally pass another form to it, which you can't know while designing.

Core data dirty flag not being set

I have a core data document based cocoa app that is working well except for one slightly odd problem.
For some reason, if I make a change to any of my fields the menu/window don't seem to recognize it - ie. the red close button doesn't get the black 'dirty' indicator and the File/Save menu item isn't enabled. However, if I attempt to close the application (via command-Q), I do get the popup asking me if I want to save my changes.
It seems that the document's dirty flag is being set, but the window/menu items aren't reacting to it. I am curious as to where I might look to see why this might be the case. I suspect that it may have something to do with my window not knowing about my ManagedObjectContext...
The only slightly atypical behaviour is that my document's makeWindowControllers method has been overridden and I am adding my window controllers using a call to my document's [self addWindowController:xxx] method. My window controllers subclass from NSWindowController so I had to add my own instance variable to each window controller to hold the ManagedObjectContext, but I suspect that this isn't getting passed to the window/menu. Not sure what the normal pattern is here...
Anyway, any thoughts would be much appreciated. Thanks
From the description it sounds like your UI elements are not actually bound to the document itself. If so, then the UI elements are not observing the document and are not reacting to changes in the document. Check the bindings.
Thanks in part to TechZen, and also re-reading my own question (in particular, where I said "I suspect that it may have something to do with my window not knowing about my ManagedObjectContext") I started to look at the bindings for my WindowController subclass.
As it turned out, I hadn't bound the window outlet for the File's Owner to my actual NSWindow. As soon as I did that, the black dirty dot and the window's menus started behaving correctly.

User controls as "screens" in a webpart

I'm workin on my first webpart.
I use some number of user controls as screens. And I have a trouble here.
First screen contains a list of dynamically created options (hyperlinks). After user made a decision with click, I want to change the screen and pass to the new screen some parameters.
My dicision is to load all controls I need on webpart creation. Controls I don't need right now I make invisible.
SomeUserControl1 uc1 = (SomeUserControl1)Page.LoadControl("~/_controltemplates/SomeUserControl1.ascx");
SomeUserControl2 uc2 = (SomeUserControl2)Page.LoadControl("~/_controltemplates/SomeUserControl2.ascx");
uc2.Visible = false;
Controls.Add(uc1);
Controls.Add(uc2);
Option in first user control realized as LinkButtons (serverside). OnClik event calls a special method in the webpart class and in this method i change a visibility of my user controls and pass some parameters to usercontrol2.
I don't like this approach. Are there different ways to realize described functionality?
Thanks!
You need use a ASP.NET Wizard Control, it does what you exactly you want.
From a design standpoint what you are doing looks a little bit frightening. You should think about nesting the various user controls into a single user control that you can use as the face of your webpart. Keep the coupling between the various user controls loose and think about implementing the Observer pattern if you need to do things like playing with control visibility.

Resources