Search code examples
c#windows-phone-7reflectionsystem-tray

How to make a touchable notice top bar in windows phone?


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.


Solution

  • 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.