How restart the animation in UWP using Visible property? - xaml

In a UWP app, I show an error bar in the bottom of the Window, like Mail app of Windows 10. The idea is when I change the Visibility to Collapsed, the animation would start.
The animation only works once, when the window is created. I would like to trigger the animation each time that Visibility changes from Visible to Collapsed. The XAML code is:
<StackPanel Grid.Row="1" Canvas.ZIndex="10" Background="{StaticResource BackError}" VerticalAlignment="Bottom" Name="NotificationStackPanel" >
<StackPanel.Transitions>
<TransitionCollection>
<PaneThemeTransition Edge="Bottom"/>
</TransitionCollection>
</StackPanel.Transitions>
<TextBlock VerticalAlignment="Center" Foreground="White" Margin="20" Name="NotificationText"/>
</StackPanel>
My workaround for now is removing the entire StackPanel and recreating it again, it works but it seems too ugly.

PaneThemeTransition is a transition animation. Usually we use panel animations (PaneThemeTransition) to show UI that slides a significant distance into the screen, such as a task pane or a custom soft keyboard.
Transition animations have built-in triggers (the transition) that can run automatically when UI elements are added, removed, reordered, and so on. Transition animations are simple to apply. But we do not have much control over the timing and order of the animation effects. 
To restart the panel animation, you can remove the StackPanel form its parent element and then add it again like:
private bool isVisible = true;
private void ChangeVisibility()
{
    if (isVisible)
    {
        //Root is a Grid which is the parent element of NotificationStackPanel
        Root.Children.Remove(NotificationStackPanel);
    }
    else
    {
        Root.Children.Add(NotificationStackPanel);
    }
    isVisible = !isVisible;
}

Related

Saving position and locations drag item by jQuery ui sortable

I'm trying to make a sortable drag item where I click the save changes button that will save the layout. The sortable is working correctly, but the saving and loading aren't working properly. When I refresh, everything goes back to the original my second point is that when I drag an item that position save in local storage and then refresh the page item gets in the previous position. I'm hoping someone can help me out here.
URL
           
'jquery.skedTape.min.js', jquery.skedTape.css   ,jquery.skedTape.min.css                              
'jquery.skedTape.js',
'bootstrap-popover-x.min.js',
https://github.com/HifsaAnsari/dragdrop

Swiping elements inside a TabView - Xamarin.Froms

I have an horizontal TabView with 2 TabViewItems. In one of them I have a WebView that loads a certain website. The website has a long string of text that can be swiped horizontally.
<TabView>
<TabViewItem>
<WebView />
</TabViewItem>
<TabViewItem>
<!-- More XAML code -->
</TabViewItem>
<TabView>
Here is the problem: When IsSwipeEnabled is set to True (which is the default value of the property) the swipe gesture has no effect on the text. The focus is on the tab and swiping horizontally just brings on screen the other tab.
Is there a way to keep IsSwipedEnabled set to True but pass the focus to the text when the gesture happens on it?
Check TabView source code we can find actually it uses CarouselView to implement the scrolling effect.
However , it's not recommended to place a Webview on a CarouselView/ScrollView , the swipe gesture would generate conflict.
The workaround is
Disable Swipe gesture of TableView in Webview page , and recover it in another page .
<TabView IsSwipeEnabled="False" SelectionChanged="TabView_SelectionChanged">
<TabViewItem Text="111">
<WebView/>
</TabViewItem>
<TabViewItem Text="222">
<Label Text="test"/>
</TabViewItem>
</TabView>
private void TabView_SelectionChanged(object sender, Xamarin.CommunityToolkit.UI.Views.TabSelectionChangedEventArgs e)
{
if(e.NewPosition == 0)
{
(sender as TabView).IsSwipeEnabled = false;
}
else
{
(sender as TabView).IsSwipeEnabled = true;
}
}

Shopify: How to return only children of specified menu/linklist?

Let's assume we have a menu:
Main Menu
  └ Home
  └ About Us
    └ Locations
      └ Montreal
      └ Ottawa
I would like to return links only nested below "Locations" from our "Main Menu".
Expected Output:
- Montreal
- Ottawa
Is this possible?
Yes, it is possible only.You can just follow the below instructions and do it yourself.
Open your admin panel and open the Navigation part.
If you don't aware of Navigation means paste the below URL to change main menu
https://your-domain-name.myshopify.com/admin/menus
Note: You must replace your-domain-name
Here you can view the Menu list, For your understanding, I have attached the screenshot.
After click the Main menu it will redirects to another page.
In that page you can able to delete or add the list items.
If you have any query means, kindly ask again.

Keep element in view while scrolling

Simpel question, I have a windows phone page that contains a scrollviewer with inside it an image, a textblock and a richtextbox.
Now when the user starts scrolling I want to keep the textblock in view on top when the image has scrolled outside the page.
So the effect is, user starts scrolling upwards, everything scrolls upwards, when the image is outside the page, the textblock stays at the top of the page but the richtextbox keeps scrolling upwards.
Any thoughts?
Here is a way to reach this result:
First, the layout. I've set a grid, with two rows. The first is empty, and will host the header when we need to freeze it. The second row contains the scrollviewer.
Inside the scrollviewer, I've put the controls in a grid, but you can use whatever container suits you.
<ScrollViewer Grid.Row="1"
Margin="0"
Padding="0"
x:Name="ParentScroll"
ManipulationMode="Control"
MouseMove="ParentScroll_MouseMove">
<Grid x:Name="ChildGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Image Source="Picture.jpg" Grid.Row="0"/>
<TextBlock Text="Header" Grid.Row="1" x:Name="TextHeader" />
<RichTextBox Grid.Row="2" x:Name="RichText">
<Paragraph>
<Bold>RichTextBox</Bold>
<!-- More stuff -->
</Paragraph>
</RichTextBox>
</Grid>
</ScrollViewer>
I use the MouseMove event to be notified of the scrolling event. You can also dig into the template, extract the ScrollBar control, and subscribe to the ValueChanged event, as described here: http://social.msdn.microsoft.com/Forums/wpapps/en-US/81fcd34e-6ec9-48d0-891e-c53a53344553/scrollviewer-synchronization
Note that you need to set ManipulationMode to Control or the position of the controls won't be updated at a smooth rate. I guess it's due to some internal optimization.
In the code behind, I use the TransformToVisual method to compute the relative position of the controls to the ScrollViewer. This way, I can know when the header goes out of view. When it does, I remove it from the child grid, and put it outside of the ScrollViewer, in the parent grid. When the top of the RichTextBox goes out of view, I put the header back into the ScrollViewer:
private void ParentScroll_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
if (Grid.GetRow(this.TextHeader) == 1)
{
var generalTransform = TextHeader.TransformToVisual(ParentScroll);
var childToParentCoordinates = generalTransform.Transform(new Point(0, 0));
if (childToParentCoordinates.Y < 0)
{
this.ChildGrid.Children.Remove(this.TextHeader);
this.ParentGrid.Children.Add(this.TextHeader);
Grid.SetRow(this.TextHeader, 0);
}
}
else
{
var generalTransform = RichText.TransformToVisual(ParentScroll);
var childToParentCoordinates = generalTransform.Transform(new Point(0, 0));
if (childToParentCoordinates.Y > 0)
{
this.ParentGrid.Children.Remove(this.TextHeader);
this.ChildGrid.Children.Add(this.TextHeader);
Grid.SetRow(this.TextHeader, 1);
}
}
There may be less-hacky ways to reach the same results, but this solution seems to work smoothly in the emulator.
I've found a working solution myself... the complete detail is available on my blog here... it contains also the link to my demo project on GitHub.
The trick was to get hold of the VerticallScrollBar inside the ScrollViewer and to set the ManipulationMode to Control to get enough feedback on the UI thread.
With the scroll offset information of the scrollbar we than animate the specific ui element we want to keep in view.

Toggling TopMost in VB.NET

I have a form that has to be on top for a period of time, and then can be set behind other windows normally. Is there anything in addition to setting Me.TopMost to True or False that needs to be done? I ask because it doesn't seem to be working.
It should present no problem. The following code (C#, sorry for that, no VB.NET environment available where I am right now) sets TopMost to true, waits for 5 seconds and then toggles TopMost back to false.
private void MakeMeTopmostForAWhile()
{
this.TopMost = true;
ThreadPool.QueueUserWorkItem(state =>
{
Thread.Sleep(5000);
this.Invoke((Action)delegate { this.TopMost = false; });
});
}
Note that this does not affect the Z-order of the window immediately; when TopMost is set to false, the window will still be on top of other windows. If the window is on top of another window that is also topmost, it will move so that the other topmost window is not covered, but it will remain on top of other non-topmost windows.
Update
Here is the above code in VB.NET (auto-converted, not tested):
Private Sub MakeMeTopmostForAWhile()
    Me.TopMost = True
    ThreadPool.QueueUserWorkItem(Function(state) Do
        Thread.Sleep(5000)
        Me.Invoke(DirectCast(Function() Do
            Me.TopMost = False
        End Function, Action))
    End Function)
End Sub