FlipView doesn't show the arrows to navigate in desktop, when more items are added in runtime - windows

I'm using FlipView to show some items in a page. The webservice I'm getting the data from support paging, so I'm adding the next page of items to the FlipView when the user has scrolled to the current last item e.g. if the page size is 5, I'm adding 5 more items whenever the SelectedIndex of FlipView is 4,9,14,19 etc. (index starts at 0).
FlipView has two tiny arrows that we can use in desktop environment (using Mouse) to navigate through the FlipView. When we are at the last item, the right arrow would disappear, because we cannot go any further. Now, if I add more items to the list at this point, the right arrow doesn't reappear, so it doesn't give the impression that there are more items in FlipView. The right arrow would only reappear if
We hover mouse on the left arrow
We click at the location where the right arrow should be
Which isn't a good solution and it requires further user education. Is there any way to address this issue?
Here is a git repo that shows the issue: https://github.com/4bh1sh3k/FlipViewDemo. To repro the issue, scroll till the last item, and then use the button below to add more items to the FlipView.

This should be determined by the control itself. If you do want the button displayed automatically, you may force the next button (which named NextButtonHorizontal in FlipView style and template) to visible after more items added. For how to get the NextButtonHorizontal button you could use VisualTreeHelper class. For example:
private void OnButtonClick(object sender, RoutedEventArgs e)
{
AddImageUris();
IEnumerable<Button> items = FindVisualChildren<Button>(myFlipView);
foreach (Button item in items)
{
if (item.Name == "NextButtonHorizontal")
{
item.Visibility = Visibility;
}
}
}
private static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject
{
if (depObj != null)
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
if (child != null && child is T)
{
yield return (T)child;
}
foreach (T childOfChild in FindVisualChildren<T>(child))
{
yield return childOfChild;
}
}
}
}
By the way, this can resolve your issue but I'm not very recommend that. Avoid using a flip view control for larger collections, for large collections, consider a ListView or GridView. More details please reference FlipView guidelines.

Related

How to do the navigations based on Gestures in windows phone apps?

In my app I have a Home page and 2 other pages, So I want to navigate from one page to another and viceversa, When I'm horizontally swiping from right to left and when I'm horizontally swiping from left to right it should be navigated to Home page.
Suppose, We are on Home page on swiping from right to left( Home Page ---> Page1, again swipe ---> Page2, again swipe ---> Page1 ...Like that..... ) and on all the page if I swipe from left to right it should be navigated to Home page. How to do this in windows phone 8 app ?
My Code:
if (e.HorizontalVelocity < 0) //when it is true it should navigate to next index value
{
try
{
Pivot_Main.SelectedIndex++;// here every time it's showing the same index value it is not incrementing
switch (Pivot_Main.SelectedIndex)
{
case 0:
Pivot_Main.SelectedIndex = 0;
txtBlock_Pivot_Heading.Text = "Temperature";
var brush = new SolidColorBrush(Color.FromArgb(0xFF, 0x8C, 0xC6, 0x3F));
b_celcius = true;
temperature_Page_Clear();
txtBlock_OptText.Text = "ºC";
btn_OptText.Content = "ºC";
Grid_PivotHeading.Background = brush;
Canvas_Home.Background = brush;
Canvas_DisplayName.Width = 55;
// btn_OptText.SetValue(Canvas.LeftProperty, 380.0);
break;
case 1:
Pivot_Main.SelectedIndex = 1;
txtBlock_Pivot_Heading.Text = "Length";
length_Page_Clear();
b_meter = true;
}
}
}
Please Help me, Genuine help is appreciated.
You have multiple options here.
If you can manage to do things in one page then Pivot or Panorama controls will be sufficient.
Also,if you need that every page should be different and you want to use NavigationService.Navigate() to go from one page to another then, you have event called Flick.you can manage to handle left/right swipes through this through HorizontalVelocity and VerticalVelocity of that events.
To use Flick Gesture you will need to add this code in your xaml w.r.t. to your UI element:
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener Flick="OnFlick"/>
</toolkit:GestureService.GestureListener>
and in .cs its handler:
private void OnFlick(object sender, FlickGestureEventArgs e)
{
// User flicked towards left
if (e.HorizontalVelocity < 0)
{
//your respective navigation to other page
}
// User flicked towards right
if (e.HorizontalVelocity > 0)
{
//your respective navigation to other page
}
Details of Gesture support you can get here

How can I set a property for AutoMouseScroll and Mouse hower property to UltraDropdown?

I am using UltraDropDown control to bind a column of one UltraGrid control to list People category in list format.
This drop-down control have more than 25 items and show 8 categories Max, it's very fine. Now whenever I click on drop-down control to see all people category list then i have to hold scroll bar and drag down to see all categories. but I want to show all categories when I mouse scroll and its automatically move up and down to show all, and one more thing I want, when i mouse hover on listed categories then hover item should be shaded or colored.
Please help on both topic.
Thanks & Regards,
Shashi Bhushan Jaiswal
I believe that the first requirement is by default as behavior. Are you handling the MouseWheel event for this to not work?
Here is the code for your second requirement but I do not know if it is a good approach to use the MouseHover event as you like but this is your requirement:
void ultraDropDown1_MouseHover(object sender, EventArgs e)
{
if (cell != null && isInItem) {cell.Cell.Appearance.BackColor = Color.Red;}
}
CellUIElement cell;
bool isInItem = false;
private void ultraDropDown1_MouseEnterElement(object sender, Infragistics.Win.UIElementEventArgs e)
{
if (e.Element is EditorWithTextDisplayTextUIElement && e.Element.Parent.Parent is CellUIElement)
{
cell = (CellUIElement)e.Element.Parent.Parent;
isInItem = true;
}
else isInItem = false;
}

Windows Phone 7 Selection_Changed automatically

currently I'm developing an app for WP7 but came across a little problem with a Listbox event call Selection_Change. The problem is that when i return to the page that contains the listbox the selection_change event triggers without being changed at all or without any user input. The listbox code is similar to this:
private void lsbHistory_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int index = lsbHistory.SelectedIndex;
NavigationService.Navigate(new Uri("/Views/NextPage, UriKind.Relative));
}
On the page I navigate to, the only way out of the navigated page is by pressing back button or start button meaning that it will return to the page that contains the listbox. When I Navigate back the selection change triggers leading me sometimes to a exception. Has anyone been through this before?
Consider always checking if it's -1 (the default value).
private void lsbHistory_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int index = lsbHistory.SelectedIndex;
if (index != -1)
{
NavigationService.Navigate(new Uri("/Views/NextPage, UriKind.Relative));
lsbHistory.SelectedIndex = -1; // Set it to -1, to enable re-selection.
}
}
Also, you should consider wrapping the Navigate call in Dispatcher.BeginInvoke to have a better, more smooth, page transition.
The event will be fired when the list is populated.
The simplest solution for you will probably be to add a check that there is nothing selected before triggering your navigation:
if (lsbHistory.SelectedIndex > -1)
{
// do navigation
}
One thing to notice is that when you navigate back to the page which containt the ListBox, the ListBox still has the SelectedItem set to the value it had when the user navigated away. This means that lsbHistory.SelectedIndex will get the index of the item which was selected when the user navigated forward.
Maybe there's something in your code which presumes that the ListBox's SelectedItem is null when the user navigates to the page?

Make A Panel Visible C# Winforms - Visual Studio

What I want is that whenever I choose a certain index in my ComboBox a certain panel will become visible.
So Here is What I've done:
I've created a ComboBox
I've created 2 Panels
I've set the visibility of the 2 Panels in their properties tab to FALSE
However I was not able to set them to visible when somebody selects something on my ComboBox.
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox3.SelectedIndex == 0)
{
panel9.Visible();
}
}
Note: I've docked the 2 Panels in the same GroupBox.
What's wrong with my code T_T. It says non vocable member. :((
EDIT** I have a new problem. Everytime I pick another option. The panel which has been set to visible won't get back to hidden.
It will appear when I choose Index 1 but when I choose Index 2 it will also appear o.O?
It says non invocable member as you are calling visible, which is a property, as a method when you place the () after it. Just set the property to a value as below
panel9.Visible = true;
It should be panel9.Visible = true;
In that case just do something like this
if(index == 1)
{
panel9.Visible = true;
panel10.visible = false;
}
else
{
panel9.Visible = false;
panel10.Visible = true;
}

Unselecting a WP7 listbox item on click

I've seen similar questions asked about WPF, but none of the proposed solutions seem to work under Windows Phone 7.
Basically, I've got a listbox where the behavior needs to be
1) when user taps an item in the list, it's selected.
2) when user taps any other item, the first is unselected and the tapped item is selected (so far this is just normal single select list box behavior)
3) when user taps an already selected item, the item "unselects" (so that there is no selected item at all anymore).
It's certainly easy enough to intercept the MouseLeftButtonDown event and clear the selection, but the ui system appears to continue processing the tab and turns around an reselects the item I've just unselected.
At first, I thought binding could be the problem, and the list items +are+ bound to an observableCollection, but neither the "selectedItem" or "selectedIndex" are bound at all.
I tried setting the event args handled prop to true:
e.Handled = true
but no change.
Any ideas?
Use MouseLeftButtonUp() rather than MouseLeftButtonDown().
private object _selected;
private void ListBox_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
var list = (ListBox) sender;
if (list.SelectedItem == _selected)
{
list.SelectedIndex = -1;
_selected = null;
}
else
{
_selected = list.SelectedItem;
}
}

Resources