VSTO Outlook: Detect when custom task pane is being resized manually - outlook

I have and VSTO Outlook Add-in which has a custom task pane at the top. Now I am trying to detect if there is a way or some trick to detect when the custom task pane is being resized (its height). Height resize can be done through the menu or clicking on the custom task pane splitter. So how can I detect that the user is being resizing the custom task pane height? is there some way?

You can override the OnResize method in any user control, for example, the following code can be used for the Outlook form region instance or custom task pane:
protected override void OnResize(EventArgs e)
{
// add your code here
base.OnResize(e);
}
Or just handle the Resize event of the UserControl class:
private void UserControl1_Resize(object sender, EventArgs e)
{
// add your code here
}

Related

VSTO Outlook: Handle event when custom task pane changes its height

The custom task pane has a down arrow button at the top right corner which if you click on it a contextual menu appears showing two options:
Resize
Close
I would like to handle the event when user resize the height of the custom task pane and gather the height set by the user. Is that possible? if so, how? what event do I need to handle?
Your task pane is a user control where you could override methods in the following way:
protected override void OnSizeChanged(EventArgs e)
{
// this.Size
base.OnSizeChanged(e);
}
Don't forget that you could also override the windows procedure which processes Windows messages - WndProc, where you could detect such actions like closing (see WM_CLOSE).

Xamarin Forms Using page transitions

I have a problem. I created an app, that uses a wizzard to set some of your settings, so to do that, I created a navigation page. In that navigation page I created my own NavigationBar with a back and next arrow and these functions:
private void arrowBack_Clicked(object sender, EventArgs e)
{
Navigation.PopAsync();
}
private void arrowNext_Clicked(object sender, EventArgs e)
{
Navigation.PushAsync(new Devices(), true);
}
But now every page slides in from the bottom, but I want them to slide in from the right and for back I want them to slide in from the left. Now I already found a few projects to create this like this: https://github.com/jsuarezruiz/xamarin-forms-page-transitions, but I was wondering if there isn't something much simpler, because it looks to me like a very wanted feature!
Any suggestions how to make NavigationPage animations from the sides?
The navigation that you are experiencing it is due to the fact that you are using PushModalAsync and PopModalAsync.
Using this your new page will come from the bottom of the screen.
If you change your code to use PushAsync and PopAsync instead (without the word Modal), you will get the navigation that you are looking for.
To get the sliding animation you should set the animation parameter to true, like this:
Navigation.PushAsync(page, true);

How can i capture a global touch event?

i have a Xamarin application in UWP that has multiple screens which build up while being used. on each screen there are multiple controls in which they can enter information. what i am trying to do is - if the screen has not had any interaction in the way of a touch / click from the user then to time out and go back to the beginning. i can of course capture the event of each control that has been touched and reset but i was wondering if there is like a 'Global' touch event that will fire when the screen is touched.
if there is like a 'Global' touch event that will fire when the screen is touched.
Sure, For UWP you could add PointerEntered event handler for current CoreWindow and it is Global on the top level. Please refer the following steps.
public MainPage()
{
this.InitializeComponent();
Window.Current.CoreWindow.PointerEntered += CoreWindow_PointerEntered;
}
private void CoreWindow_PointerEntered(Windows.UI.Core.CoreWindow sender, Windows.UI.Core.PointerEventArgs args)
{
// do some stuff
}

Remove background color from buttons in Listbox (Windows Phone)

I have a function connected to a buttonclick in i Listbox. It sets the background color of the selected button. The problem with this is that i only want one button at a time to act as selected. With this solution every button clicked gets the green background... how can i reset the buttons that are not selected to a black background?
private void SettingsChangeRegionButton_Click(object sender, RoutedEventArgs e)
{
Button clickedButton = sender as Button;
clickedButton.Background = new SolidColorBrush(Colors.Green);
RssStream choosenStream = GetRssStreamFromName(clickedButton.Content.ToString());
}
If you want a button to be green while it is being pressed you should change the color which is used as the background in the Pressed state.
If you just want to highlight which is the currently selected item in the list(box) then you need to change the styling of the item in the Selected state.
Sorry, if you know this but to pre-empt your next question: You can change a template by selecting an item in the objects and timeline window in blend and selecting "Edit Template" (or "Edit Additional Templates" as appropriate).

Binding Panorama.SelectedIndexProperty in WP7

First, SelectedIndex is not exposed in markup, so you have to do it in code behind, right?
Second, I have set the binding in code behind:
Binding binding = new Binding("Main.PanoSelectedIndex.ObservedObject");
binding.Mode = BindingMode.TwoWay;
rootPano.SetBinding(Panorama.SelectedIndexProperty, binding);`
(ObservedObject implements iNotifyChanged)
The binding path points to my Main view model, and I can see that the PanoramaItem is updating the binding. However,the panorama does not respond when something else (a MVVM Light command) changes the binding. Any ideas?
Thanks,
Roger
To quote from the Windows Phone Developer FAQ
Panorama is designed so the user is in control, there fore you cannot set SelectedIndex programmatically, or force a navigation to a panorama item.
You can set the DefaultItem so that when your panorama is first launched, the panorama navigates to that item, but you can’t navigate programmatically beyond that. DefaultItem can also be used so that a back navigation feels like the item where the user was at did not change.
UPDATE: You can use the DefaultItem to save/restore the selection for a Panorama as shown below (code from Jeff Prosise's recent blog post):
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
// Save the Panorama control's SelectedIndex in page state
State["Index"] = PanoramaControl.SelectedIndex;
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// Restore the Panorama control's SelectedIndex
if (State.ContainsKey("Index"))
PanoramaControl.DefaultItem = PanoramaControl.Items[(int)State["Index"]];
}
As far as I know SelectedIndex is a readonly property in Panorama ( Weired why WP7 SDK made it readonly). So you will get only UI change back to your VM, and you cant update UI through the VM propertychange.
And DefaultItem is the property which used to set the index programatically.
Again the issue of programatically setting an already instantiated Panorama is that, the alignment of the Title and Panoramaitem wont be in sync. Anyway I am not discouraging but there is still some chance of hack there.

Resources