मैं ListBox के लिए स्क्रॉलिंग को कैसे एनिमेट कर सकता हूं? मुझे पता है कि मैं scrollIntoView का उपयोग कर सकता हूं लेकिन मैं इसे कैसे एनिमेट कर सकता हूं? मैं एक सूची बॉक्स Item से दूसरे में स्थानांतरित करने के लिए तीर कुंजियों को दबा देना चाहता हूं।स्क्रॉल एनीमेशन
उत्तर
यहाँ एक किसी न किसी तरह कार्यान्वयन नीचे दिए गए लिंक
http://aniscrollviewer.codeplex.com/
VerticalOffset
संपत्ति केवल पढ़ने के लिए है, ताकि इसके बजाय आप ScrollViewer
जो बारी में ScrollToVerticalOffset
करता है पर एक संलग्न संपत्ति VerticalOffset
उपयोग कर सकते हैं के रूप में ही दृष्टिकोण पर आधारित है। यह संलग्न संपत्ति एनिमेटेड हो सकती है।
आप ItemsControl
AnimateScrollIntoView
नामक एक एक्सटेंशन विधि भी बना सकते हैं।
यह इस
listBox.AnimateScrollIntoView(yourItem);
ScrollViewerBehavior
की तरह कॉलpublic class ScrollViewerBehavior
{
public static DependencyProperty VerticalOffsetProperty =
DependencyProperty.RegisterAttached("VerticalOffset",
typeof(double),
typeof(ScrollViewerBehavior),
new UIPropertyMetadata(0.0, OnVerticalOffsetChanged));
public static void SetVerticalOffset(FrameworkElement target, double value)
{
target.SetValue(VerticalOffsetProperty, value);
}
public static double GetVerticalOffset(FrameworkElement target)
{
return (double)target.GetValue(VerticalOffsetProperty);
}
private static void OnVerticalOffsetChanged(DependencyObject target, DependencyPropertyChangedEventArgs e)
{
ScrollViewer scrollViewer = target as ScrollViewer;
if (scrollViewer != null)
{
scrollViewer.ScrollToVerticalOffset((double)e.NewValue);
}
}
}
ItemsControlExtensions
public static class ItemsControlExtensions
{
public static void AnimateScrollIntoView(this ItemsControl itemsControl, object item)
{
ScrollViewer scrollViewer = VisualTreeHelpers.GetVisualChild<ScrollViewer>(itemsControl);
UIElement container = itemsControl.ItemContainerGenerator.ContainerFromItem(item) as UIElement;
int index = itemsControl.ItemContainerGenerator.IndexFromContainer(container);
double toValue = scrollViewer.ScrollableHeight * ((double)index/itemsControl.Items.Count);
Point relativePoint = container.TranslatePoint(new Point(0.0, 0.0), Window.GetWindow(container));
DoubleAnimation verticalAnimation = new DoubleAnimation();
verticalAnimation.From = scrollViewer.VerticalOffset;
verticalAnimation.To = toValue;
verticalAnimation.DecelerationRatio = .2;
verticalAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(1000));
Storyboard storyboard = new Storyboard();
storyboard.Children.Add(verticalAnimation);
Storyboard.SetTarget(verticalAnimation, scrollViewer);
Storyboard.SetTargetProperty(verticalAnimation, new PropertyPath(ScrollViewerBehavior.VerticalOffsetProperty));
storyboard.Begin();
}
}
और चूंकि आप भीपर भी नियंत्रण प्राप्त करने की जरूरत हैआप .... इस
public static class VisualTreeHelpers
{
public static T GetVisualChild<T>(DependencyObject parent) where T : Visual
{
T child = default(T);
int numVisuals = VisualTreeHelper.GetChildrenCount(parent);
for (int i = 0; i < numVisuals; i++)
{
Visual v = (Visual)VisualTreeHelper.GetChild(parent, i);
child = v as T;
if (child == null)
{
child = GetVisualChild<T>(v);
}
if (child != null)
{
break;
}
}
return child;
}
}
इस article पर एक नज़र डालें, यह बताता है कि कैसे स्क्रॉलिंग एनिमेट करें और टच जेस्चर जोड़ें। पृष्ठ के निचले हिस्से में स्रोत डाउनलोड करें और WpfScrollContent समाधान देखें। मैं डब्ल्यूपीएफ लिस्टबॉक्स का विस्तार करूंगा और उस पर स्क्रॉल एनीमेशन जोड़ूंगा जिससे आप नियंत्रण का पुन: उपयोग कर सकें।
टूटा हुआ लिंक की आवश्यकता होगी साल – patrickbadley
पोस्ट पर 2 पहले ... – evanb
@evanb जो यही कारण है कि जवाब है कि लेकिन लिंक कुछ भी नहीं होते हैं हतोत्साहित किया जाता है। –
- 1. एनीमेशन के साथ स्क्रॉल करने के लिए
- 2. एनीमेशन UIScrollView एनीमेशन के बाद एनीमेशन
- 3. स्क्रॉल
- 4. एक jQuery एनीमेशन को पीछे और आगे स्क्रॉल करना
- 5. एनीमेशन के बिना क्षैतिज स्क्रॉल दृश्य को स्क्रॉल करने के लिए कैसे करें
- 6. स्क्रॉल इवेंट
- 7. क्षैतिज स्क्रॉलव्यू, एनीमेशन
- 8. एंड्रॉइड अल्फा एनीमेशन: एनीमेशन
- 9. कोर एनीमेशन एनीमेशन ट्रैकिंग
- 10. एनीमेशन के साथ स्क्रॉलिंग
- 11. कस्टम एनीमेशन
- 12. एनीमेशन
- 13. एनीमेशन
- 14. एनीमेशन
- 15. एनीमेशन
- 16. एनीमेशन?
- 17. एनीमेशन
- 18. एनीमेशन
- 19. एनीमेशन
- 20. एनीमेशन
- 21. एनीमेशन
- 22. एनीमेशन
- 23. एनीमेशन
- 24. Google प्लस टाइल एनीमेशन
- 25. एंड्रॉइड वेबव्यू चिकनी स्क्रॉल
- 26. एंड्रॉइड: स्क्रॉलर एनीमेशन?
- 27. स्क्रॉल
- 28. स्क्रॉल
- 29. स्क्रॉल
- 30. स्क्रॉल
अगर मैं क्षैतिज स्क्रॉल करना चाहता हूं तो एनीमेशन क्या होगा? – Cobold
कोड में कोई त्रुटि हो सकती है: 'scrollViewer.ScrollableHeight * ((डबल) अनुक्रमणिका/आइटम नियंत्रण। ITems.Count); ' 'scrollViewer.ScrollableHeight * ((डबल) अनुक्रमणिका/(itemsControl.Items.Count -1) होना चाहिए; ' उदाहरण के लिए, यदि सूची 12 तत्व शामिल हैं और मैं पिछले एक (सूचकांक 11) करने के लिए स्क्रॉल करना चाहते हैं, परिणाम बनना पड़ता है ' scrollViewer.ScrollableHeight * 1' भी शून्य से भाग से सावधान:) – sim1
@ sim1: इसे लंबे समय तक नहीं देखा है, इसलिए मुझे यकीन है कि आप सही हैं। अद्यतन के लिए धन्यवाद :) –