一个放在执行中,一个在另一个地方
界面
<ListView x:Name="lvActionEditList" Grid.Row="0" Grid.Column="0" SelectionChanged="lv_SelectionChanged" Margin="10,10,0,10" ScrollViewer.ScrollChanged="Q22" >
System.Timers.Timer t = new System.Timers.Timer(100); //实例化Timer类,设置间隔时间为10000毫秒;
t.Elapsed += new System.Timers.ElapsedEventHandler(theout); //到达时间的时候执行事件;
t.AutoReset = false; //设置是执行一次(false)还是一直执行(true);
t.Enabled = true; //是否执行System.Timers.Timer.Elapsed事件;
public void theout(object source, System.Timers.ElapsedEventArgs e)
{
MessageBox.Show("OK!");
}
停止,减少正在运行的进程
t.Enabled = false;
t.stop();
t.Elapsed -= new System.Timers.ElapsedEventHandler(theout);
滚动条响应
//界面里面
ScrollViewer.ScrollChanged="Q22"
//cs里面
private void Q22(object sender, ScrollChangedEventArgs e)
{
MessageBox.Show("111OK!");
}
显示滚动条位置
private void button2_Click(object sender, RoutedEventArgs e)
{
ListViewAutomationPeer lvap = new ListViewAutomationPeer(lvActionEditList);
var svap = lvap.GetPattern(PatternInterface.Scroll) as ScrollViewerAutomationPeer;
var scroll = svap.Owner as ScrollViewer;
//此处添加你想要对TreeView自身滚动条的操作///
scroll.ScrollToVerticalOffset(scroll.VerticalOffset + 1); //向下调节垂直滚动条的位置;
//scroll.VerticalOffset 当前偏移量的总数
double qqq =lvActionEditList.Items.Count;
double qqq2 = scroll.ViewportHeight;
MessageBox.Show("可见" +Convert.ToString(qqq2)); //可见数目
MessageBox.Show(Convert.ToString(scroll.VerticalOffset)); //第一条在整个的数目
MessageBox.Show("总数" +Convert.ToString(qqq)); //总数
}