C# SurfaceScrollView:淡出不可见内容
是否有可能淡出SurfaceScrollViewer中不可见的内容 如回答中所述,我尝试了这个,但无法识别任何褪色:C# SurfaceScrollView:淡出不可见内容,c#,.net,wpf,pixelsense,C#,.net,Wpf,Pixelsense,是否有可能淡出SurfaceScrollViewer中不可见的内容 如回答中所述,我尝试了这个,但无法识别任何褪色: //fading out Rectangle fade = new Rectangle(); fade.Width = 478; fade.Height = 140; fade.IsHitTestVisible = false;
//fading out
Rectangle fade = new Rectangle();
fade.Width = 478;
fade.Height = 140;
fade.IsHitTestVisible = false;
LinearGradientBrush myBrush = new LinearGradientBrush();
myBrush.GradientStops.Add(new GradientStop(Color.FromArgb(50, 50,50,50), 0.0));
myBrush.GradientStops.Add(new GradientStop(Colors.Transparent, 0.5));
myBrush.GradientStops.Add(new GradientStop(Color.FromArgb(50, 50, 50, 50), 1.0));
fade.Fill = myBrush;
我最终以这种方式解决了这个问题:
GradientStopCollection collection = new GradientStopCollection();
collection.Add(new GradientStop(Colors.Transparent, 0));
collection.Add(new GradientStop(Colors.Black, 0.1));
collection.Add(new GradientStop(Colors.Black, 0.9));
collection.Add(new GradientStop(Colors.Transparent, 1));
LinearGradientBrush brush = new LinearGradientBrush(collection);
scroller.OpacityMask = brush;
你怎么能淡出一些看不见的东西?@Axarydax好吧,让我换个说法:淡出那些几乎看不见的元素。即SurfaceScrollViewer可见部分边界处的元素。