I tried IsEngagedChanged, PointerPressed/PointerReleased, none of those events is fired when I click the AdControl. (AdRefreshed event does occur)
I am developing an Windows Store App in C#/XAML.
<ad:AdControl Height="90" x:Name="ad1" Width="728" AdUnitId="10042998" ApplicationId="d25517cb-12d4-4699-8bdc-52040c712cab" IsEngagedChanged="ad1_IsEngagedChanged_1" AdRefreshed="ad1_AdRefreshed_1" PointerPressed="ad1_PointerPressed_1" />
private void ad1_IsEngagedChanged_1(object sender, RoutedEventArgs e)
{
//not fired
}
private void ad1_AdRefreshed_1(object sender, RoutedEventArgs e)
{
//fired
}
private void ad1_PointerPressed_1(object sender, PointerRoutedEventArgs e)
{
//not fired
}
I want to award the user for clicking on the Ad.
The IsEngagedChanged-event does actually fire, but not really when you expect it to. If you use ads which causes the ad to go full-screen (click-to-fullscreen) the IsEngagedChanged-event will fire when a user clicks it. If you use a normal ad (which you did according to your adUnitId) which goes to some link, the event will not fire. It's stupid as hell.
As Walt Ritscher pointed out, this is in the docs:
Raised when the user clicks the ad, and is interacting with it rather
than the app.
Which makes one believe it would get called on any click, but it doesn't. There's so many things missing/"wrong" in the Microsoft Advertising SDK that you wanna cry.
Hope this helped someone.
Related
I have a page which is a child of a CarouselPage. The page has ImageButtons on it which have pressed and released events.
Something happens when the pressed event fires and it stops when the released event fires.
The problem I have is when you push a button down and then slide left or right causing the carousel animation to take effect the released event from the currently held button no longer fires.
This is not an issue if the user switches to another page as I can use the page changed event to tidy up.
The problem is if you start sliding to the next page and then stop it pings back to the current one and no event fires at all.
I have looked for events that may fire in this scenario but have not found anything yet.
I need a way to either get the released events to still fire or a means of detecting a partial carousel scroll so that I can do the same from another event.
I am using the latest version of everything, testing in the emulator and developing solely for Android.
ImageButton definition
<ImageButton Grid.Row="0" Grid.Column="1" Source="up.png" Pressed="ImageButton_OnPressed" Released="ImageButton_OnReleased" BackgroundColor="Transparent" CommandParameter="U"></ImageButton>
Code behind
private void ImageButton_OnPressed(object sender, EventArgs e)
{
// Action start action
}
private void ImageButton_OnReleased(object sender, EventArgs e)
{
// Action stop action
}
Page Change event on CarouselPage
private void MainPage_OnCurrentPageChanged(object sender, EventArgs e)
{
// Action stop all actions on page
}
So, as per the docs I attach a handler when I navigate to a page:
protected override void OnNavigatedTo(NavigationEventArgs e) {
/* Attach back listener to handle the back press */
SystemNavigationManager.GetForCurrentView().BackRequested += NavigationPage_BackRequested;
...
}
And I detach it when leaving:
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) {
SystemNavigationManager.GetForCurrentView().BackRequested -= NavigationPage_BackRequested;
e.Cancel = false;
}
And I mark the event as handled to prevent the system from handling it:
private void NavigationPage_BackRequested(object sender, BackRequestedEventArgs e) {
e.Handled = true;
}
But the system still handles the back click and I get navigated away. Why?
Your code shown above is working fine (tested on my machine), but the big question is: do you try to cancel a system provided navigation event or a Frame.GoBack() event implemented by the software button of your application?
SystemNavigationManager: Provides a way for an app to respond to system provided back-navigation events.
If you look at the backwards navigation documentation, only certain back buttons (hardware/software) are system provided events, e.g. the software button at the bottom in Tablet mode.
However quite a few project templates (in Visual Studio or from MVVM libraries) also provide a software back button (quite often at the top left) and wire this event to the Frame.GoBack() method. This is NOT a system provided event and can't be cancelled this way. Reasoning: You (or the framework used) is calling the GoBack() explicitly, so why would it have to be cancelled in this scenario.
i searched google lot to know how can i programmatically click on cross button X using c#. i got the below code which is used for different purpose.
private void Form1_FormClosing(object sender, FormClosingEventArgs e) {
if (string.Equals((sender as Button).Name, #"CloseButton"))
// Do something proper to CloseButton.
else
// Then assume that X has been clicked and act accordingly.
}
so anyone can tell me How to programmatically click on cross button for closing form. thanks
To check the close reason you can use the CloseReason enum
private void Form_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.ApplicationExitCall)
// Do something...
}
If you want to programattically close a form you can use
this.Close();
This will launch the FormClosing event that is displayed above.
I hope this helps.
If you want to emulate close click investigate SendMessage to send WM_CLOSE to you window.
I have a webBrowser on my UI. I ask if it is possible that it is not displayed directly but instead through an image, and I want that the image is updated only when the LoadCompleted event is received.
How to do?
I'm not sure if I understood your question, but if I did, you basically want to show the loaded web page only when its rendering has finished.
If so, this code should do the trick (I'm assuming you hooked the "LoadCompleted" event up to the "webBrowser1_LoadCompleted" method). This code uses a Button ("button1") to trigger the navigation, but you can use it in any other place.
//here is the code that triggers the navigation: when the button is clicked, I hide the
//webBrowser and then navigate to the page (here I used Google as an example)
private void button1_Click(object sender, RoutedEventArgs e)
{
webBrowser1.Visibility = Visibility.Hidden;
webBrowser1.Navigate(new Uri("http://www.google.it"));
}
private void webBrowser1_LoadCompleted(object sender, NavigationEventArgs e)
{
webBrowser1.Visibility = Visibility.Visible;
}
Keep in mind, though, that not showing anything to the user for a long period of time (as with a heavy page) is not always a good idea, depending on the kind of application you're writing. This is up to you, though.
(I decided to leave the previous answer if someone needs it)
If you want to leave the previous page visible until the new one appears, then I think you need a Windows DLL. This is how I would do it.
At the top of the code file, insert these two import statements:
using System.Runtime.InteropServices;
using System.Windows.Interop;
Then you need to declare your DLL function like this (in the Window class):
[DllImport("user32")]
private static extern int LockWindowUpdate (IntPtr hWnd);
Then, let's modify the code in the previous answer a little bit:
private void button1_Click(object sender, RoutedEventArgs e)
{
IntPtr handle = new WindowInteropHelper(Application.Current.MainWindow).Handle;
LockWindowUpdate(handle);
webBrowser1.Navigate(new Uri("http://www.google.it"));
}
private void webBrowser1_DocumentCompleted(object sender, NavigationEventArgs e)
{
LockWindowUpdate(new IntPtr(0));
}
This should keep the last loaded page on screen until the new page has completed its rendering; as you may imagine, the DLL function simply locks the update of the Window by passing its handle. The handle 0 unlocks it.
I'm working on an add-in for Outlook 2010. I've created a new Ribbon Tab with a dropdown box. I'd like for the data in the dropdown to update when I click the dropdown button, but nothing is occurring. I've written the sample code below for testing purposes and nothing fires:
private void dropDown1_ButtonClick(object sender, RibbonControlEventArgs e)
{
MessageBox.Show("Dropdown CLick");
}
This is as simple as it gets, but nothing is firing. Any ideas of what I might be doing wrong? The only other code that exists in this ribbon right now is what loads the data.
Thank you
From my understanding
private void dropDown1_Click(object sender, RibbonControlEventArgs e)
{
MessageBox.Show("Dropdown CLick");
}
is what you wanna do. No where did I see ButtonClick as the proper tag.