how to move to specific section in panorama? - windows-phone

In windows phone app ?I am using Panorama control having 3 sections like sports videos and photos.
My app contains one "other" page where names of the pages are present.
Problem: when I click on video page button it should navigate to video section of panorama control
So how to visit a specific section?

You can take a global static variable in App.xaml.cs like this
public static int SelectedIndexPanorama;
now in "Other" Page assign the value to this variable on specific navigation
case "sports":
App.SelectedIndexPanorama=0;
NavigationService.Navigate(new Uri("/sports.xaml? ", UriKind.RelativeOrAbsolute));
break;
case "video":
App.SelectedIndexPanorama=1;
NavigationService.Navigate(new Uri("/video.xaml", UriKind.RelativeOrAbsolute));
break;
And, on panorama page OnNavigatedToEvent, write the code to set the selectedItem
myPanorama.SetValue(Panorama.SelectedItemProperty, myPanorama.Items[App.SelectedIndexPanorama]);

Related

Selenium webdriver not finding add to cart button in Amazon

After selecting a product and opening it in another page Im not able to click on add to cart button in amazon using selenium.
If you are not switching to other page, Add to card option will not be located.
Switch to the opened page and then try to click on the button.
handles = driver.window_handles
driver.switch_to.window(handles[1])
driver.find_element_by_id("add-to-cart-button").click()
If you have done this, share the code you have tried and error you get.
Without HTML page you are trying to perform, it is difficult to pinpoint exactly. However, I would like to take a stab at it considering these:
Click on product in home page
Product opens in a new tab window
Click on add to cart
P.S: I will write it using Java since you haven't mentioned on the language being used. Will be similar in others as well
Click on product in home page
List <Webelement> productCheck = driver.findElements(By.xpath("<xpath of the product>"))
if (productCheck.size() == 0){
// do something
else {
driver.findElement(By.xpath("<xpath of the product>")).click();
}
Product opens in a new tab window and Click on add to cart
String parent = driver.getWindowHandle();
List<String> windows = new ArrayList<String>(driver.getWindowHandles());
driver.switchTo().window(windows.get(1));
// Inside the tab window
List <WebElement> addtoCartButton = driver.findElements(By.xpath("<xpath of Add to cart button>"));
if (addtoCartButton.size() == 0 ) {
// do something
else {
driver.findElement(By.xpath("<xpath of Add to cart button>")).click();
}
// do whatever you want in the new tab and if you want to switch back then:
driver.switchTo().window(parent);

Sencha Touch 2.0 Multiple List Item Buttons

Does anyone know if it is possible to have multiple icon buttons on a Sencha Touch list item that listen to different events? If so, how can I accomplish this?
For instance, say I have a list of people and there's an icon for email, phone and a map to their location for each person. I want to show 3 small icons and be able to map each icon to do 3 separate actions.
This depends on how you are creating your buttons.
If the buttons are simple HTML using itemTpl, you can just listen to the itemtap event on List and use the event argument to detect which button you pressed. You could do this via a custom attribute or even a className:
myListItemTapListener: function(list, index, target, e) {
var el = Ext.get(e.getTarget());
if (el.hasClass('map')) {
this.navigate(index);
} else if(el.hasClass('email')) {
this.email(index);
} else if(el.hasClass('phone')) {
this.phone(index);
}
}
If your buttons are actual Ext.Button's inside a component List, you can simply add a listener onto each button when you create the component. There is an example of how to do this in the DataView Guide in the Sencha Docs.
Component DataView may help you. You can see this [guide]: http://docs.sencha.com/touch/2-0/#!/guide/dataview-section-4
I have wrote a [demo]: https://github.com/hs3180/Sencha-Touch-Component-DataView
, in app/view/,
Main.js, a dataview component with useComponets true, and set defaultType to 'demo.view.Item'.
Item.js, a DataItem, the visible content of each item is a panel ( in Card.js ). I use datamap to link name in record ( within store ) to userName ( in demo.view.Card ).
Card.js, a Panel for each person. A user name title and 3 buttons.

Windows 8 app: How to pass a parameter on GoBack()?

There are a lot of samples showing how to pass a parameter on navigating to a page in Window 8 (WinRT). But I could not find any hint for passing parameters going back.
Situation: The user navigates to a details page of same data. The data is passed to the page by
Frame.Navigate(typeof(DedtailsPage), data);
How can I pass back the changed data on GoBack()?
Store the reference to data somewhere and retrieve it when you navigate back?
Also note that it's best not to pass objects other than simple strings or values between pages, since only simple types are supported for storing frame navigation state in case your app gets suspended.
I know, that this is a very bad idea, but usualy I use this:
To write:
Frame rootFrame = Window.Current.Content as Frame;
rootFrame.Tag = myObject1;
To read:
Frame rootFrame = Window.Current.Content as Frame;
var myObject2 = rootFrame.Tag;
I've made another choice to handle this.
Keep in mind that I'm a Xamarin developer (not Forms!) so i was looking for a solution which was similar for all platforms: iOS, Android and Windows.
I am a great fun of events, rather than passing objects or storing globals.
So the best choice to pass data from PageB (the child) to PageA (the parent) is to communicate via events.
Some notes: In iOS and Android, when you navigate from a "page" to "page" you can do this by passing an instance of the target object you want to navigate to. In iOS you create an instance of a custom UIViewController. In Android you create an instance of a custom Fragment. Doing this allow you to attach events handler to your instances.
An example:
var controller = new ExtrasViewController();
controller.ExtraSelected += ExtrasFragment_ExtraSelected;
controller.ExtrasCleared += ExtrasFragment_ExtrasCleared;
this.NavigationController.PushViewController(controller, false);
In WinRT Apps you are only allowed to pass "types" of target page to navigate to. So the only way to attach event handlers to your page instance is to use the OnNavigatedFrom method from the calling page. So suppose you are in PageA and want to attach some event handlers to your PageB, before it become active, simply write in your PageA "code behind":
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
var page = e.Content as ExtraBody;
if(page != null)
{
page.ExtraSelected += ExtrasFragment_ExtraSelected;
page.ExtrasCleared += ExtrasFragment_ExtrasCleared;
}
}

Why isn't the page data tab showing in the Designer?

I'm editing a page in the ToolTwist Designer, and I have all the normal tabs shown - edit page, navpoint, test page, source, etc, but the "Page Data" tab is not showing. How can I make the tab show, so I can enter page data for my page?
The page data tab only appears if there is a widget on your page that requires page data. You also need to editing the navpoint, rather than the page, because the page data belongs to the navpoint, and a single page definition might be shared by many navpoints. In other words, the page data allows widgets to appear different at various locations (navpoints) within the website.
If you are developing a widget that you wish to have use page data, you need to do the following:
In the Widget Controller class, implement the "UsesPageData" interface. This tells the Designer that the page data tab needs to be displayed when you click on a navpoint that references a page that included this widget, and on the tab it creates a section where the XML for this widget can be entered, specific to that particular navpoint.
public class CarouselTab extends WbdWidgetController implements UsesPageData
To give the user an indication of what XML the widget expects, you need to implement a method that returns template XML code. For example:
public XData getInitialPageData(WbdWidget instance)
{
StringBuffer xml = new StringBuffer();
xml.append("\n");
xml.append("\n");
xml.append(" id01\n");
xml.append(" [Label 01]\n");
xml.append(" [Add your widget here 01]\n");
xml.append("\n");
xml.append("\n");
xml.append(" id02\n");
xml.append(" [Label 02]\n");
xml.append(" [Add your widget here 02]\n");
xml.append("\n");
xml.append("");
return new XData(xml);
}
Define a property that defines a name to be displayed above where you enter the XML on the page data tab:
protected void init(WbdWidget instance) throws WbdException
{
instance.defineProperty(new WbdStringProperty("pageDataSection", null, "PageDataSection", ""));
...
}
Use the page data when you are generating the page:
#Override
public void renderForJSP(WbdGenerator generator, WbdWidget instance, UimHelper ud, WbdRenderHelper rh) throws WbdException
{
...
Xpc xpc = ud.getXpc();
xpc.start("tooltwist.wbd.getPagedata", "select");
xpc.attrib("navpointId", WbdSession.getNavpointId(ud.getCredentials()));
xpc.attrib("pageDataSection", pageDataSection);
XData pagedata = xpc.run();
// Do something with the page data
...
}

Windows Phone 7 Control Caching - 'Element is already the child of another element'

I'm trying to speed up my windows phone 7 page load times. I have a 'static' page that has a dynamically created in a Panorama control - static meaning that the content never changes.
On the first load I look at my config file, create the individual PanoramaItem controls and add them to the main Panorama control. I'm trying to keep a List in a static place so that the initial creation would only happen once and I could just add a fully rendered version to my Panorama control when the page was rendered.
Works fine on first load, but when I try to add the cached PanoramaItems to the Panorama control I get the message "Element is already the child of another element". This makes sense since I already added before. But I can see a way to disconnect the PanoramaItems with the first Panorama control...
I could be going about the control caching thing all wrong as well... Let me know if there's another way to do this.
You can use Panorama.Items.Remove(pivotItem) for this
As an example
With the following page fields
PanoramaItem pi;
bool blahShown = false;
On the press of this button, the control is first instantiated and displayed and on subsequent presses removed and readded without instantiation.
private void button1_Click(object sender, RoutedEventArgs e)
{
if (pi == null) {
pi = new PanoramaItem();
pi.Header = "blah";
}
if (blahShown) {
Pano.Items.Remove(pi);
blahShown = false;
} else {
Pano.Items.Add(pi);
blahShown = true;
}
}