I have one ListView and ContentFrame (Frame Control) inside of my MainPage.xaml.
For example if I Navigate page Content.xaml to this ContentFrame and then I need to call Navigate from his Content.xaml. But Navigate have to change content of main application Frame (it is parental Frame).
How can I do this?
Keep a reference to your root frame somewhere - e.g. as a static property on the App class and use that to call Navigate(). Alternatively you can walk up the visual or perhaps also logical tree and find the next frame to get the reference.
Related
Everybody.
In UWP Windows 10, I want to get the current navigated page in frame as object.
So I can call some methods from that page.
I have main page that is updating some model in async mode, but binding is not updating controls. I need to call:
Bindings.Update();
on page that is currently navigated in the frame in order to update some TextBlocks.
How to manage this?
In my MainPage I have 3 frames,and trying to change the page of my FrameMain(frame) to another page,the problem is that I am doing this in another page inside a second frame if I use
NavigationService.Navigate(new Uri("/View/CreateAcc.xaml", UriKind.Relative));
It loads my current frame with the page,but I want the FrameMain to load this page, so I tried:
MainPage main = new MainPage();
main.FrameMain.Navigate(new Uri("/View/CreateAcc.xaml", UriKind.Relative));
wich didn't do anything...
sorry about the confuse text if someone can help i only saw examples of changing pages inside the MainPage.
Change the way of doing to get what i wanted,instead of using frame implemented two WrapPanel at exactly the same position and used the property Visibility to put one Visible and the other Collapsed and vice verse to change Panel showing.
Scenario:
- I have a page with an iFrame Text Editor and a button in the page too.
- I switched from the parent frame to the iFrame to read from the Text Editor body
- After reading from the body of the Text Editor, I want to click on the button in the parent frame of the page.
- For this I tried to switch back to the parent frame from the iFrame using the following statement:
webDriver.SwitchTo().DefaultContent();
- But still I am not able to find the button element which resides in the parent frame.
I appreciate your help!
Thanks
Thats for your responses guys. It is solved!
The solution:
While I use the webDriver.SwitchTo().DefaultContent(); it switches the webDriver to the top most window of the page. [Previously I was looking for the button element in this window and therefore was not able to find it as the button was sitting in the main frame of the page]
After switching to the main window, I switched the webDriver again to the main frame of the page. This main frame had the button element. Thus I was able to find the button element. And this slved the issue!
So the final code doesn't have webDriver.SwitchTo().DefaultContent(); but has the following in its place:
_webDriver.SwitchTo().Window(windowHandle);
_webDriver.SwitchTo().Frame("mainFrame");
Note: windowHandle in the above code is the handle of the top most window of the page. I guess it's value may change according to the browsers, not sure though.
The following code worked fine:
driver.switchTo().parentFrame();
I was struggling with a similar problem and found that I could switch back by Window Handle:
string currentWindow = Driver.CurrentWindowHandle;
// switch to frame and do stuff..
Driver.SwitchTo().Window(currentWindow); // switch back
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.
On a Frame in silverlight I want to be able to navigate to an existing instance of a Page. In short this is what I want:
Page p = ...; // initialize the page and set some of the properties
contentframe.Navigate(p);
Instead of using an Uri from which the page is created.
Can this be achieved (as in WPF), or should the frame rather be replaced by a ContentControl?
Edit: More clarity: Is there a way that NavigationService.Navigate(object root) that is available in WPF can be simulated in silverlight?
You question seems really quite confused.
should the frame rather be replaced by a ContentControl?
That would imply that you don't have good reason to have the frame there in the first place and you aren't using a navigating framework. In which case certainly you should replace the Frame with something else.
If you can replace the frame with something else the there is no need for your "Page" to be of type Page, it may as well be a UserControl.
It can all boil do down to have this simple Xaml:-
<Border x:Name="content" />
and this cs:-
UserControl p = ...;
content.Child = p;
Edit:
You need to keep the frame therefore you can't replace it with a ContentControl.
You might just assign your Page directly to the Frame Content property. However I'm not sure what would happen if you then click the back button. I suspect it would navigate to the page prior to the page you replaced.
Another option would be to us a static service to push your page properties on to a stack, you page can then pop them off this stack when initialising. This would allow you to navigate using a Uri to your page.
The problem you are facing is the same problem that I am facing. An event happens outside the frame, and the page has no idea that the event has ocured, but it needs to be notified of that event.
Now what can be done is force the page within that frame to refresh itself or handle those events by 1: storing the page's state temporarily, and b) passing "commands" through the query string.