Invoking Message dialog from Settings Flyout causes Message Dialog to flicker - windows-8

I'm trying to invoke messagedialog from setting flyout for my Windows 8 Metro app but it's causing the message dialog to flicker. Below is the code.
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
SettingsPane.GetForCurrentView().CommandsRequested+=settings_CommandsRequested;
}
private void Settings_CommandsRequested(SettingsPane sender, SetttingsPaneCommandsRequestedEventArgs args)
{
SettingsCommand cmd = new SettingsCommand("test","test1232",new UICommandInvokedHandler(CreateDialog));
args.Request.ApplicationCommands.Add(cmd);
}
private void CreateDialog(IUICommand command)
{
if (ReferenceEquals(command.Id, "cmd"))
{
MessageDialog md = new MessageDialog("Hi");
md.ShowAsync();
}
}

I've contacted official microsoft dev-support and their response was:
"MessageDialog is not recommended within the SettingsFlyout".
So in case you want to implement something simillar to support user's decision from the SettingsPane, you should either:
1) Enable toggling feature in the Flyout.
2) Desiging the SettingsFlyout so it lets the user make decision (for example in Logout cases, add Yes/no buttons inside the settingsFlyout) - Thats the option I chose.

Related

Manipulation events of MediaElement not fire when on FullWindows mode

When I set player not in fullscreen (player.IsFullWindows = false), event work normally but when change player to full screen all manipulation event not work. Anyone have solution?
<MediaElement Name="player"
Margin="10,5" ManipulationCompleted="player_ManipulationCompleted"
ManipulationDelta="Grid_ManipulationDelta"
ManipulationMode="TranslateX"
>
I can reproduce this scenario by enabling both the IsFullWindow="True" and the AreTransportControlsEnabled="True". I think it makes sense, because when we are in the Full Window mode, it will go to the new layer named FullWindowMediaRoot instead of the MediaElement. Inside the FullWindowMediaRoot, it is the MediaTransportControls. You can see that clearly by using the Live Visual Tree as following:
So when we are in the Full Window mode, we need to handle the manipulation event of the TransportControls instead of the manipulation event of the MediaElement as following:
public MainPage()
{
this.InitializeComponent();
player.TransportControls.ManipulationMode = ManipulationModes.TranslateX;
player.TransportControls.ManipulationDelta += TransportControls_ManipulationDelta;
player.TransportControls.ManipulationCompleted += TransportControls_ManipulationCompleted;
}
private void TransportControls_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
}
private void TransportControls_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
}
Thanks.

Adding a page before the hub page in a Windows Phone 8.1 store app

I'm building a Windows Universal Store App, concentrating first on the Windows Phone 8.1 app. I'm basing my app on a hub app. I want to add a splash page to the app startup to replace the static splash screen with a XAML based animation. I am confused by navigation since it all seems to be set up and owned by the hub page.
I have looked at
Mike Taulty's blog post about Windows/Phone 8.1–Frame, Page, NavigationHelper, SuspensionManager;
Quickstart: Navigating between pages;
How to extend the splash screen; and
Navigation Patterns
In fact the last of those explicitly states that "hub pages are the user's entry point to the app".
How do I add pages to my hub app that the user will encounter before the hub, like a splash page or a logon screen?
Typically no sooner had I posted the question than I saw where to find the answer. When NavigationHelper is added to the project along with the hub page it includes comments explaining how to use it:
To make use of NavigationHelper, follow these two steps or
start with a BasicPage or any other Page item template other than BlankPage.
1) Create an instance of the NavigationHelper somewhere such as in the
constructor for the page and register a callback for the LoadState and
SaveState events.
public MyPage()
{
this.InitializeComponent();
var navigationHelper = new NavigationHelper(this);
this.navigationHelper.LoadState += navigationHelper_LoadState;
this.navigationHelper.SaveState += navigationHelper_SaveState;
}
private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
{
}
private async void navigationHelper_SaveState(object sender, LoadStateEventArgs e)
{
}
2) Register the page to call into the NavigationHelper whenever the page participates
in navigation by overriding the Windows.UI.Xaml.Controls.Page.OnNavigatedTo
and Windows.UI.Xaml.Controls.Page.OnNavigatedFrom events.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
navigationHelper.OnNavigatedTo(e);
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
navigationHelper.OnNavigatedFrom(e);
}
That boiler-plate code only required slight changes in my page: take out the async, and make navigationHelper an instance variable.
Then to start in another page follow the instructions in Set start page in Windows Phone 8.1 universal app to edit App.xaml.cs thus:
#if WINDOWS_PHONE_APP
if (!rootFrame.Navigate(typeof(SplashPage), e.Arguments))
{
throw new Exception("Failed to create initial page");
}
#endif
#if WINDOWS_APP
if (!rootFrame.Navigate(typeof(HubPage), e.Arguments))
{
throw new Exception("Failed to create initial page");
}
#endif
Then in SplashPage.xaml.cs when I need to navigate to the hub page I add
if (rootFrame.Navigate(typeof(HubPage)))
{
Window.Current.Content = rootFrame;
}
else
{
throw new Exception("Failed to create hub page");
}

Enable - Disable a button while threading vsto for ms word

I'am very new to threading and quite unclear as to why this is happening in my code, when I click on a button that verifies hyperlinks in my document, I start a new thread that does the verification once it starts I want to disable the ribbon button and enable it again after thread finished but this is not happening and I dont know what is the mistake .Here is what I have tried so far:
public class Alpha :Ribbon1
{
// This method that will be called when the thread is started
public void Beta()
{
foreach() { //do something } after this loop ,enable the button again
button.enable=true //not applying
} }
private void button_Click(object sender, RibbonControlEventArgs e)
{
Alpha oAlpha = new Alpha();
// Create the thread object, passing in the Alpha.Beta method
Thread oThread = new Thread(new ThreadStart(oAlpha.Beta));
// MessageBox.Show("Please wait till the document is checked for invalid links");
// Start the thread
oThread.Start();
button7.Label = "Pls wait";
button7.Enabled = false;
}
Ribbon needs to be rendered again after enable/disable for change to take effect, you can do this by calling IRibbonUI.Invalidate()

Replicate Hardware Back Button Functionality from UI in Windows Phone

I'm trying to write a windows phone application and am wondering if it's possible to have a software button in the UI that does the same thing as the hardware back button (just sends a system back command). I can't seem to find any information on how to do this online.
try this:
XAML:
<Button x:Name="btnBack" Content="Back" Click="btnBack_Click"></Button>
CS:
private void btnBack_Click(object sender, RoutedEventArgs e)
{
if (NavigationService.CanGoBack)
NavigationService.GoBack();
else
App.Current.Terminate();
}
This would work as same Back button. if any back-state is there it would go to that state or if not it would close (Terminate) the Application.
you can override the back button function
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
//Do your work here
base.OnBackKeyPress(e);
}

Get information from different hidden Form C++/clr

I have a Windows Form application I am creating in C++/CLR Visual Studio 2012.
The goal is to have the user input values into the form named Home Page. Then once all the info is filled in they click a button and the Home Page form is hidden and then second form called Setup Info is shown.
The part I need help with is the info from Home Page needs to be accessible in Setup Info. To get an idea of how my files are setup this is the youtube video I followed to create my C++ Windows Form Application Click Here.
In my HomePage.h
// Button that will hide the Home Page Form and then show the SetupInfo Form.
private: System::Void Start_Click(System::Object^ sender, System::EventArgs^ e) {
this->Hide();
SetupInfo^ SetupInfo = gcnew ExcelToPPT::SeuUpInfo();
SetupInfo->Show();
}
In my Setup Info.H
// When Setup Info is loaded button1 will have the text of textbox1 from Home Page Form.
private: System::Void SetupInfo_Load(System::Object^ sender, System::EventArgs^ e) {
button1->Text = HomePage->Textbox1->Text;
}
This is the general idea but it doesn't work. How do I get this to work?
Let me know if you need any more information.
[EDIT]
I am able to do this through extern global variables, but is there another way to directly access the text text boxes?
Also wen I exit out of my Setup Information it doesn't seem to kill my program how do I solve this problem?
The simplest thing would probably be to just pass your Home Page form to the new SetUpInfo form.
private: System::Void Start_Click(System::Object^ sender, System::EventArgs^ e) {
this->Hide();
SetUpInfo^ setUpInfo = gcnew ExcelToPPT::SetUpInfo(this);
setUpInfo->Show(); ^^^^
}
In SetUpInfo.h:
public ref class SetUpInfo : Form
{
private:
HomePage^ homePage;
public:
SetUpInfo(HomePage^ homePage);
};
In SetUpInfo.cpp:
SetUpInfo::SetUpInfo(HomePage^ homePage)
{
this->homePage = homePage;
}
void SetUpInfo::SetUpInfo_Load(System::Object^ sender, System::EventArgs^ e)
{
button1->Text = this->homePage->Textbox1->Text;
}