作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个项目列表,我想慢慢地垂直滚动,直到鼠标悬停在项目列表上。然后,将出现一个滚动条。我坚持的部分是让列表不断循环的最佳方式。所以如果你有:
-----
A
B
C
D
E
-----
它会滚动并看起来像这样:
----
D
E
A
B
C
----
有没有办法让我在没有两个集合的情况下做到这一点?
最佳答案
你可以这样做:
ObservableCollection<string> myList;
public MainPage()
{
InitializeComponent();
myList = new ObservableCollection<string>();
myList.Add("A");
myList.Add("B");
myList.Add("C");
myList.Add("D");
myList.Add("E");
System.Threading.Timer t = new System.Threading.Timer(new System.Threading.TimerCallback(TimerFired));
t.Change(500, 500);
listBox2.ItemsSource = myList ;
}
private void TimerFired(object sender)
{
Pop();
}
private delegate void PopDelegate();
private void Pop()
{
if (this.Dispatcher.CheckAccess())
{
string item = myList[myList.Count - 1];
myList.RemoveAt(myList.Count - 1);
myList.Insert(0, item);
}
else
{
this.Dispatcher.BeginInvoke(new PopDelegate(Pop), null);
}
}
关于c# - 如何在 silverlight 中制作垂直自动收报机?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11000607/
我是一名优秀的程序员,十分优秀!