Why would I do that, anyway? Here it is: My application bar item respond to click like this:
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Click="Customization" x:Name="Custom"
It allows the user to go to settings page, but the user still has something to do before the app navigates. The actual event that will make the app navigates is triggered by a normal button. So, before, the user do that, I'd like to remove the event suscriber from the application bar item.
If I try this in the beginning of method "Customization":
Custom.Click -= new System.EventHandler(Customization);
I got NullReferenceException.
That's how I do for my "normal" items and it works. This is the first time I'm using a System.EventHandler, so there's probably something that I'm missing.
Later in the scenario, I'd like to be able to re-add this suscriber to the application bar item.
Any help appreciated, thank you.
You can't access AppBarButtons that way.
Try
((ApplicationBarIconButton)ApplicationBar.Buttons[0]).Click -= new System.EventHandler(Customization);
Related
I'm relatively new to UWP, but I have good WPF background.
What I need is a simple context menu for the application. User "right taps" anywhere, menu opens, user taps an item and things happen.
It looks basic and simple. First I add MenuFlyout element to my Application.Resources. Then, in MainPage I just show it with ShowAt method. Works.
To my greatest surprise when I tried to add events to menu items, VS told me it's invalid, events cannot be added in App.xaml.
So here's my assignment (in App.xaml.cs):
MainContextMenu = (MenuFlyout)Resources["MainContextMenu"];
MainContextMenu.Items.First(i => i.Name == "NavToCalibration").Tapped += NavToCalibration_Tapped;
The problem is - the handler is never called. I run my app, open the menu, click on the item and nothing happens. The assigned method is not called. What am I doing wrong? Why the handler is not called?
The assignment IS executed on application launch.
I'm also surprised I haven't been able to find any example or tutorial on doing such a simple and basic thing.
There is a good reason I use app-wide context menu instead of other controls. The app displays test images, it has to be full-screen (or maximized window) without interfering elements.
Now I will try to move my menu to the page resources, my pages will have different context menus anyway. But I'm really curious what's wrong in MenuFlyout defined in App.xaml?
Whoa. I tried to move my MenuFlyout to MainPage. I was able to assign Tapped event in XAML. And it also is not triggered! Now I'm completely lost. Any ideas?
I have a Form Server running in Outlook and I specify a different MessageClass (say IPM.Note.Test) for items which are to be handled by my form server. If you select an item, with MessageClass IPM.Note.Test, in the explorer view, and try to Forward from ribbon button, I prevent the user from doing so, by hooking into Forward command.
In OL 2013, if you have reading pane visible, and select an item in Explorer, you can see its preview and can Forward/Reply/ReplyAll from toolbar at the top of the reading-pane, which would create an InlineResponse.
I want to hook into this Forward action, and prevent the user from doing so, as I do for the Explorer-Ribbon Forward command.
I am aware of the Explorer.InlineResponse event which is fired on any action which creates an Inline Response, but this event is fired after the action, not before it, and it fires for Reply, ReplyAll and Forward, all three of them. I only want to intercept Forward. There is no information in the event to tell which action triggered it.
Is there a way to identify the the action which triggered the event, before the InlineResponse is created?
Or is there a way to stop the InlineResponse from being created? (From code, as I know you can disable it in OL options).
Or is there a way to disable these actions/inline response from Explorer.SelectionChange event?
I would appreciate any help.
Thanks.
MailItem object exposes the Actions collection. Retrieve the Forward action, set the Action.Enabled property to true, call MailItem.Save.
You need to set the Enabled property of the corresponding Action object instance to false. True if the action is enabled in the application and false - if the action is disabled.
Thanks guys for taking time to answer this.
Something else came up and I put this issue on hold for a bit.
As I mentioned earlier, I have my own Form Server with a different MessageClass. So the MailItem object I get in ExplorerSelectionChange event, is not a pure Outlook MailItem, its rather my MailItem and unfortunately, at the moment, its unable to get Actions property on it, probably because my Form Server implementation doesnt return a proper one.
So, although, for a normal MailItem, Enabled property will work, it doesnt solve my problem ... :(
I x-posted to Outlook Dev Forum as well, and someone suggested the following:
Private Sub myOlExp_InlineResponse(ByVal Item As Object)
Dim a As MailItem
Set a = Item
If a.To = "" Then
a.Close olDiscard ‘close the mail item
MsgBox "Forward is not supported"
End If
End Sub
Although a bit hacky, and not a great user-experience, but I'm taking this for an answer for the moment, as it works.
Shared here, in case someone else comes looking for it.
Complete thread
I'd like to write some code that fires when the layout details screen is opened. Is there an event, some sort of API or some way to hijack Sitecore UI to allow me to do this? There's nothing in the Sitecore.config events sectiont hat looks relevant.
What I want to do is capture the ID of the item for which I'm currently updating so that I can use it in custom controls later on.
I'm using Sitecore 6.6.
Marek Musielak's answer is great. An alternative would be to change the command fired from the 'Details' Button - Look for item:setlayoutdetails in the commands.config.
You could create your own class that does your work then instantiates Sitecore.Shell.Framework.Commands.SetLayoutDetails afterwards.
You can override the \sitecore\shell\Applications\Content Manager\Dialogs\LayoutDetails\LayoutDetails.xml and change its code beside:
<CodeBeside
Type="Sitecore.Shell.Applications.ContentManager.Dialogs.LayoutDetails.LayoutDetailsForm,Sitecore.Client"/>
to inherit from your custom class that will simply inherits from LayoutDetailsForm and overrides e.g. OnLoad method.
How to make a touchable notice top bar in windows phone ?
I am new to C# and windows phone world.So may be my question has a simple
way to solve,but I google a lot ,and didn't work out.
here is my purpose: I have a timer running throughout my app,it request a
service for notice info every one hour, and show a "notice bar" on the top of
screen.
it is easy to get the information ,but when I want to show them to the Page,
here is my problem:
1.
I used system tray to show my info.
It works,but then I found there is no touch or click event for Progress
Indication bar.
I even add an event to Touch.FrameReported in App.xaml.cs , but still ,
when i touch the system tray area, the event doesn't fire.
2.
Then I want to use a Dynamic way to achieve it: add a text block to the
current page
I got the current page handler ,but case I only know the current page
handler's type is PhoneApplicationPage, I can't get my Root UI element
(all my page has a root element named "LayoutRoot")
And when I try to use reflect method to get the "LayoutRoot" property,
the return value is null.
The code looks like this :
Type type = PhoneApplicationPageHandler.getType()<
//I checked,the type is my page's type
type.getProperty("LayoutRoot") or type.getField("LayoutRoot")
//they all return null
BTW: LayoutRoot is a grid, and it is described in my page's .xmal file.
Now My option is to make all my page inherit a defalut page ,in this page ,I will
implement a method to fulfill my second way to simulate a "touchable top bar".
but I think this coding is ugly .
So, can anyone tell me :
1.how to add touch event to a SystemTray
or
2.how to get a handler of an ui element which is described in xaml, while I only have a PhoneApplicationPage type handler of that page.
You may use
1) a toast prompt described here http://windowsphonegeek.com/articles/WP7-Toast-Prompt-in-depth
2)or shell toast described here http://www.c-sharpcorner.com/UploadFile/ae35ca/working-with-toast-notification-in%C2%A0windows-phone-7/ according to what suits your requirement the best. 3)You may also create a custom control which you may place on the top on your mainPage and handle its tap event accordingly.
I am building a win 8 app which has a textbox control inside a hierarchy of elements like ScrollViewer->Stackpanel->Grid->Image & TextBox. The textBox contain a tapped event to navigate to a page. This textbox_tapped event is not at all firing. I am not getting any error or exceptions also. Can somebody tell me the solution for getting this? Thank you.
Maybe something to do with the fact that you are testing it on a normal PC with a mouse, so its not a tap, though I'm not sure about that. You might get a similar result by using the "GotFocus" event instead.