Pivot detect when animation completes - xaml

Is there a way to detect when Pivot animation completes after swipe? I tried the PivotItemLoaded event, but it does not work. I also tried delaying another work for 1 second when SelectedIndex changes but it's not a very good solution.

you have to use gesture flick event.like below
XAML
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener Flick="OnFlick"/>
</toolkit:GestureService.GestureListener>
C# Code
private void OnFlick(object sender, FlickGestureEventArgs e)
{
var vm = DataContext as SelectedCatalogViewModel;
if (vm != null)
{
// User flicked towards left
if (e.HorizontalVelocity < 0)
{
// Load the next image
LoadNextPage(null);
}
// User flicked towards right
if (e.HorizontalVelocity > 0)
{
// Load the previous image
LoadPreviousPage();
}
}
}
Hope it will help you ....

Related

Multiline button in Xamarin? is not working

Using
is not working. Instead my button only appears to say "First Line."
<Button Text="First Line
Second Line"/>
Am I doing this incorrectly? Is there another simple way to make the text go onto the second line?
I test it on Android,it works well,Did you run on ios ? I think this is mainly a problem with iOS because Android will wrap the text by default.
If you want run on ios,you could use customrenderer to achieve this.
[assembly: ExportRenderer(typeof(Button), typeof(iosbutton))]
namespace EntryCa.iOS
{
class iosbutton :ButtonRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.TitleLabel.LineBreakMode = UILineBreakMode.WordWrap;
Control.TitleLabel.Lines = 0;
Control.TitleLabel.TextAlignment = UITextAlignment.Center;
}
}
}
}

How to animate SettingsFlyout on dismiss

In Windows 8.1, I'm using the new SettingsFlyout control. The flyout animates in correctly and will animate out if you use the control's built-in back button to return to the Settings Charm flyout. But if you light dismiss by clicking outside the flyout, it disappears without a transition animation.
How do you animate a transition out when you light dismiss the SettingsFlyout? (I don't want to return to the Settings Charm flyout, I just want it to slide out on a light dismiss.)
Matt, what you want to do should be easily achievable but is currently not supported by the XAML SettingsFlyout API out of the box. As Jerry points out, there are transitions that allow an animate out effect (in XAML you want EdgeUIThemeTransition). Unfortunately, there is no API support on SettingsFlyout to add this transition, but you can get it to work using your own private popup to host the SettingsFlyout (more on this below):
public sealed partial class SettingsFlyout1 : SettingsFlyout
{
Popup _p;
Border _b;
public SettingsFlyout1()
{
this.InitializeComponent();
BackClick += SettingsFlyout1_BackClick;
Unloaded += SettingsFlyout1_Unloaded;
Tapped += SettingsFlyout1_Tapped;
}
void SettingsFlyout1_BackClick(object sender, BackClickEventArgs e)
{
_b.Child = null;
SettingsPane.Show();
}
void SettingsFlyout1_Unloaded(object sender, RoutedEventArgs e)
{
if (_p != null)
{
_p.IsOpen = false;
}
}
void SettingsFlyout1_Tapped(object sender, TappedRoutedEventArgs e)
{
e.Handled = true;
}
public void ShowCustom()
{
_p = new Popup();
_b = new Border();
_b.ChildTransitions = new TransitionCollection();
// TODO: if you support right-to-left builds, make sure to test all combinations of RTL operating
// system build (charms on left) and RTL flow direction for XAML app. EdgeTransitionLocation.Left
// may need to be used for RTL (and HorizontalAlignment.Left on the SettingsFlyout below).
_b.ChildTransitions.Add(new EdgeUIThemeTransition() { Edge = EdgeTransitionLocation.Right });
_b.Background = new SolidColorBrush(Colors.Transparent);
_b.Width = Window.Current.Bounds.Width;
_b.Height = Window.Current.Bounds.Height;
_b.Tapped += b_Tapped;
this.HorizontalAlignment = HorizontalAlignment.Right;
_b.Child = this;
_p.Child = _b;
_p.IsOpen = true;
}
void b_Tapped(object sender, TappedRoutedEventArgs e)
{
Border b = (Border)sender;
b.Child = null;
}
}
Full solution for this sample: https://github.com/finnigantime/Samples/tree/master/examples/Win8Xaml/SettingsFlyout_AnimateOut
I think SettingsFlyout should have API support for your scenario, so I filed a work item on the XAML team. In the future, such requests/issues can be raised on the MSDN forum as well (moderated by MSFT folks). The limitation here is that SettingsFlyout is implemented on top of Popup with IsLightDismissEnabled="True", and the light-dismiss event currently closes the Popup immediately without allowing unloading child transitions to run. I think this can be overcome and transitions can be supported at the SettingsFlyout API level to enable your scenario.
You need to use the HideEdgeUI animation
Read this: http://msdn.microsoft.com/en-us/library/windows/apps/jj655412.aspx

How to add clickhandler to the subrow of the celltablebuilder

I am able to build custom rows with celltablebuilder. When clicking on a particular anchor cell, I am able to build additional subrows for that row. This subrow has buttons, when clicking on the button I have do some action. I am able to add buttons with clickhandler in the subrow, but when clicking on the button nothing is happening clickhandler is not firing.
Can anybody please help.
protected void buildRowImpl(GridDTO rowValue, int absRowIndex ) {
buildRows(rowValue, absRowIndex, true);
if (showingFriends.contains(rowValue.getComponentId())) {
buildAdditonalRows( absRowIndex, gridDTO);
}
}
private void buildAdditonalRows(int index, GridDTO rowValue, ){
TableRowBuilder row = startRow();
td = row.startTD();
if(rowValue.getXpath() != null){
//td.text(rowValue.getXpath());
renderCell(td, createContext(1), cellTable.getColumn(1), rowValue);
}else{
td.text("");
}
td.endTD();
td = row.startTD();
Button button = new Button ();
button.setText("Save");
button.addClickHandler(new ClickHandler() {
#Override
public void onClick(ClickEvent event) {
Window.alert("ssss");
}
});
DivBuilder div = td.startDiv();
div.html(new afeHtmlBuilder().appendHtmlConstant(button.toString()).toSafeHtml());
div.end();
td.endTD();
row.endTR();
}
CellPreviewEvent provides subindex. You can use it to get subrow value.
Example usage :
dataGrid.addCellPreviewHandler(new CellPreviewEvent.Handler<TreeItem>() {
#Override
public void onCellPreview(final CellPreviewEvent<TreeItem> event) {
if(event.getNativeEvent().getType().equals(BrowserEvents.CLICK)){
if(event.getContext().getSubIndex()>0){
event.getValue().getChild(event.getContext().getSubIndex()-1);
}
}
}
});
Or you can provide custom CellPreviewEvent.Handler implementation with selectionMode. For more details you can look at AbstractHasData
I had a similar situation where i needed a widget inside a cell to listen for click events... What i found out is that the widget doesn't respond to events once you inserted it into a cell (In other words, only the actual HTML that makes up for the widget gets put into the cell, any kind of event handling isn't included). The work around is to add the events to the Cell (You can make a custom cell class for that particular cell-widget and override OnBrowserEvent to listen for events.)
See GWT: On adding custom widget to celltable losing events of the custom widgets for a more eloquent explanation and example code.

Force a view to refresh?

I'm trying to do a loading icon where once you tap on the icon, it will call the following handler:
private void refresh_btn_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
refresh_btn.Visibility = System.Windows.Visibility.Collapsed;
loading_icon.Visibility = System.Windows.Visibility.Visible;
refreshMix();
}
private void refreshMix()
{
...
refresh_btn.Visibility = System.Windows.Visibility.Collapsed;
loading_icon.Visibility = System.Windows.Visibility.Visible;
}
However, the view doesn't seem to auto-reload after I change the icon visibilities before calling refreshMix(). Is there a way to force the page to reload itself?
You are probably doing some lengthy work in refreshMix() in UI thread, right? Do this work in background thread and UI thread will be free to update page.
You need set Collapsed before Visible :
control.Visibility = System.Windows.Visibility.Collapsed;
control.Visibility = System.Windows.Visibility.Visible;
Within Silverlight there is no concept of page or view re-loading. When you change the properties of any visual element, this will be reflected on the screen the next time it is rendered.

Knowing When a Particular Data-Point is Clicked?

I have a bar graph and I want to allow the user to right click a particular bar, select some operation (add one or anything really) that will affect only that bar. Is this type of thing possible using ZedGraph?
You can add a Mouse Click event to the Form and call FindNearestObject() passing in that mouse point, you'll get back the nearest object. Something like this perhaps:
private void zedGraphControl2_MouseClick(object sender, MouseEventArgs e)
{
object nearestObject;
int index;
this.zedGraphControl2.GraphPane.FindNearestObject(new PointF(e.X, e.Y), this.CreateGraphics(), out nearestObject, out index);
if (nearestObject != null && nearestObject.GetType() == typeof(BarItem))
{
BarItem barItem = (BarItem)nearestObject;
barItem[index].Y += 1;
zedGraphControl2.Invalidate();
}
}