Silverlight 使い始めました。マウスホイールでスクロールできないなんて……。以下、ほとんど文章だけなんでわかりにくいと思いますが。
DataGridをマウスホイール対応するには、以前kazukiさんが書かれていますね。[C#][Silverlight]DataGridのマウスホイールでのスクロール その2 この方法は選択行を変える方法でしたが、もっと自然な動作させる実装が、Silverlight2.0 - DataGridをホイールマウススクロールに対応させる - PYRO :: Blog にありました。すっごいぬるぬる動くよ!
後者は、LoadingRowとUnloadingRowイベントにより現在表示されている行の最大と最小のインデックス値を保持しておいて、スクロール時にインデックス±1の行へスクロールするという手法です。
が、こっちもソートすると、うまく動いてくれませんでした。最初はソートされてもインデックス値が変わらないのかなと思ったのですが、きちんとインデックス値は変わっていました。ソート時に表示されている行だけLoadingRow、UnloadingRowイベントが発生しますが、昇順 or 降順に発生しないので最大と最小の行のインデックス値がおかしくなってしまうっぽい。
そこで、LoadingRow、UnloadingRowイベントで現在表示されている行のインデックスすべてを保持するように変えてみました。
Private indexs As New List(Of Integer)
Private Shadows Sub OnLoadingRow(ByVal sender As Object, ByVal args As DataGridRowEventArgs)
If Not indexs.Contains(args.Row.GetIndex) Then
indexs.Add(args.Row.GetIndex)
End If
End Sub
Private Shadows Sub OnUnloadingRow(ByVal sender As Object, ByVal args As DataGridRowEventArgs)
If indexs.Contains(args.Row.GetIndex) Then
indexs.Remove(args.Row.GetIndex)
End If
End Sub
ScrollIntoViewsメソッドで対象の行へスクロールするのだけど、ここで問題が。メソッドにはItemsSourcesにあるオブジェクトを指定するのだけど、IList型にキャストしてインデックス値から導き出すとItemsSource自体はソートされていないので、スクロールした位置にあるオブジェクトを指定できないのね(元のコードはListにキャストしてるけどおなじだよね? Listってなに?)。
Dim s = DirectCast(ItemsSource, System.Collections.IList)
Dim i As Integer
If mousedelta < 0 Then
i = indexs.Max + 1
ElseIf mousedelta > 0 Then
i = indexs.Min - 1
End If
If i < 0 Then
i = 0
ElseIf i > s.Count - 1 Then
i = s.Count - 1
End If
Me.ScrollIntoView(s(i), Me.Columns(0))
ItemsSourceに指定するコレクションとキャストする型を考えればなんとかなりそう! ってことでたどり着いたのが、CollectionViewModel。よくは読んでいないのだけど、M-V-VMパターンについてのエントリを訳してみた3 原題"CollectionViewModel" から原文に行ってサンプルをダウンロードして該当クラスだけとりだして使ってみると一応動きました(ItemsSourceとキャストにはICollectionView、行数を取得するのにIList型にもキャストして使用)。
ソートしてもきちんとマウスホイールでスクロールできるのだけど、ものすごいCollectionViewModel生成のところかな? 時間がかかる。150行ぐらいなのだけど、ブラウザが固まってしまう……。ううーむ? ←今ここ。
フィードバック
# re: Silverlight DataGrid マウスホイールでスクロール
2009/03/11 9:26 by
スペルが違う……。
# APNlWZztPXLKLnIsp
2011/12/13 20:28 by
Well, actually, a lot of what you write is not quite true !... well, okay, it does not matter:D
# WOBffdblvF
2011/12/22 20:26 by
J9FkLK I do`t see a feedback or the other coordinates from the blog administration!...
# re: Silverlight DataGrid ?????????????
2021/07/28 2:42 by
# re: Silverlight DataGrid ?????????????
2021/08/07 21:50 by
drug chloroquine
https://chloroquineorigin.com/# hydroxichloraquine
# Hi there Dear, are you actually visiting this site daily, if so afterward you will without doubt take fastidious knowledge.
2021/09/01 0:17 by
Hi there Dear, are you actually visiting this
site daily, if so afterward you will without doubt take fastidious
knowledge.
# Hi there Dear, are you actually visiting this site daily, if so afterward you will without doubt take fastidious knowledge.
2021/09/01 0:18 by
Hi there Dear, are you actually visiting this
site daily, if so afterward you will without doubt take fastidious
knowledge.
# Hi there Dear, are you actually visiting this site daily, if so afterward you will without doubt take fastidious knowledge.
2021/09/01 0:19 by
Hi there Dear, are you actually visiting this
site daily, if so afterward you will without doubt take fastidious
knowledge.
# Hi there Dear, are you actually visiting this site daily, if so afterward you will without doubt take fastidious knowledge.
2021/09/01 0:20 by
Hi there Dear, are you actually visiting this
site daily, if so afterward you will without doubt take fastidious
knowledge.
# Woah! I'm really digging the template/theme of this site. It's simple, yet effective. A lot of times it's challenging to get that "perfect balance" between user friendliness and visual appearance. I must say that you've done a fantastic job wit
2021/09/02 3:36 by
Woah! I'm really digging the template/theme of this site.
It's simple, yet effective. A lot of times it's challenging to
get that "perfect balance" between user friendliness and visual appearance.
I must say that you've done a fantastic job with this. Additionally, the blog loads very fast
for me on Firefox. Outstanding Blog!
# Woah! I'm really digging the template/theme of this site. It's simple, yet effective. A lot of times it's challenging to get that "perfect balance" between user friendliness and visual appearance. I must say that you've done a fantastic job wit
2021/09/02 3:37 by
Woah! I'm really digging the template/theme of this site.
It's simple, yet effective. A lot of times it's challenging to
get that "perfect balance" between user friendliness and visual appearance.
I must say that you've done a fantastic job with this. Additionally, the blog loads very fast
for me on Firefox. Outstanding Blog!
# Woah! I'm really digging the template/theme of this site. It's simple, yet effective. A lot of times it's challenging to get that "perfect balance" between user friendliness and visual appearance. I must say that you've done a fantastic job wit
2021/09/02 3:38 by
Woah! I'm really digging the template/theme of this site.
It's simple, yet effective. A lot of times it's challenging to
get that "perfect balance" between user friendliness and visual appearance.
I must say that you've done a fantastic job with this. Additionally, the blog loads very fast
for me on Firefox. Outstanding Blog!
# Woah! I'm really digging the template/theme of this site. It's simple, yet effective. A lot of times it's challenging to get that "perfect balance" between user friendliness and visual appearance. I must say that you've done a fantastic job wit
2021/09/02 3:39 by
Woah! I'm really digging the template/theme of this site.
It's simple, yet effective. A lot of times it's challenging to
get that "perfect balance" between user friendliness and visual appearance.
I must say that you've done a fantastic job with this. Additionally, the blog loads very fast
for me on Firefox. Outstanding Blog!
# If some one needs to be updated with latest technologies therefore he must be pay a visit this website and be up to date every day.
2021/09/02 19:59 by
If some one needs to be updated with latest technologies therefore he must
be pay a visit this website and be up to date every day.
# Very good info. Lucky me I found your website by chance (stumbleupon). I have saved it for later!
2021/09/03 20:59 by
Very good info. Lucky me I found your website by chance (stumbleupon).
I have saved it for later!
# Very good info. Lucky me I found your website by chance (stumbleupon). I have saved it for later!
2021/09/03 21:00 by
Very good info. Lucky me I found your website by chance (stumbleupon).
I have saved it for later!
# Very good info. Lucky me I found your website by chance (stumbleupon). I have saved it for later!
2021/09/03 21:01 by
Very good info. Lucky me I found your website by chance (stumbleupon).
I have saved it for later!
# Very good info. Lucky me I found your website by chance (stumbleupon). I have saved it for later!
2021/09/03 21:02 by
Very good info. Lucky me I found your website by chance (stumbleupon).
I have saved it for later!
# A fascinating discussion is definitely worth comment. I believe that you ought to write more about this subject, it might not be a taboo subject but typically people don't talk about such subjects. To the next! Cheers!! quest bars http://bit.ly/3jZgEA2
2021/09/11 9:36 by
A fascinating discussion is definitely worth comment.
I believe that you ought to write more about this subject, it might not
be a taboo subject but typically people don't talk about
such subjects. To the next! Cheers!! quest bars
http://bit.ly/3jZgEA2 quest bars
# A fascinating discussion is definitely worth comment. I believe that you ought to write more about this subject, it might not be a taboo subject but typically people don't talk about such subjects. To the next! Cheers!! quest bars http://bit.ly/3jZgEA2
2021/09/11 9:37 by
A fascinating discussion is definitely worth comment.
I believe that you ought to write more about this subject, it might not
be a taboo subject but typically people don't talk about
such subjects. To the next! Cheers!! quest bars
http://bit.ly/3jZgEA2 quest bars
# A fascinating discussion is definitely worth comment. I believe that you ought to write more about this subject, it might not be a taboo subject but typically people don't talk about such subjects. To the next! Cheers!! quest bars http://bit.ly/3jZgEA2
2021/09/11 9:38 by
A fascinating discussion is definitely worth comment.
I believe that you ought to write more about this subject, it might not
be a taboo subject but typically people don't talk about
such subjects. To the next! Cheers!! quest bars
http://bit.ly/3jZgEA2 quest bars
# A fascinating discussion is definitely worth comment. I believe that you ought to write more about this subject, it might not be a taboo subject but typically people don't talk about such subjects. To the next! Cheers!! quest bars http://bit.ly/3jZgEA2
2021/09/11 9:39 by
A fascinating discussion is definitely worth comment.
I believe that you ought to write more about this subject, it might not
be a taboo subject but typically people don't talk about
such subjects. To the next! Cheers!! quest bars
http://bit.ly/3jZgEA2 quest bars
# Hey there! Someone in my Myspace group shared this website with us so I came to give it a look. I'm definitely loving the information. I'm book-marking and will be tweeting this to my followers! Great blog and fantastic design. ps4 https://j.mp/3nkdKIi
2021/09/12 12:49 by
Hey there! Someone in my Myspace group shared this website with us so
I came to give it a look. I'm definitely loving the information.
I'm book-marking and will be tweeting this to my followers!
Great blog and fantastic design. ps4
https://j.mp/3nkdKIi ps4 games
# Wow that was odd. I just wrote an incredibly long comment but after I clicked submit my comment didn't appear. Grrrr... well I'm not writing all that over again. Anyways, just wanted to say great blog! quest bars https://www.iherb.com/search?kw=quest%20
2021/09/13 7:01 by
Wow that was odd. I just wrote an incredibly long
comment but after I clicked submit my comment didn't appear.
Grrrr... well I'm not writing all that over again. Anyways, just wanted to say great blog!
quest bars
https://www.iherb.com/search?kw=quest%20bars quest bars
# You really make it appear really easy together with your presentation but I to find this topic to be really one thing which I believe I'd by no means understand. It sort of feels too complicated and very extensive for me. I am taking a look forward in
2021/10/26 2:51 by
You really make it appear really easy together with your presentation but I
to find this topic to be really one thing which I believe I'd
by no means understand. It sort of feels too complicated and very extensive for me.
I am taking a look forward in your subsequent submit, I'll attempt to get
the dangle of it!
# Wow that was strange. I just wrote an very long comment but after I clicked submit my comment didn't appear. Grrrr... well I'm not writing all that over again. Regardless, just wanted to say superb blog!
2021/11/12 10:55 by
Wow that was strange. I just wrote an very long comment but after
I clicked submit my comment didn't appear. Grrrr... well I'm not writing all
that over again. Regardless, just wanted to say superb blog!
# Wow that was strange. I just wrote an very long comment but after I clicked submit my comment didn't appear. Grrrr... well I'm not writing all that over again. Regardless, just wanted to say superb blog!
2021/11/12 10:55 by
Wow that was strange. I just wrote an very long comment but after
I clicked submit my comment didn't appear. Grrrr... well I'm not writing all
that over again. Regardless, just wanted to say superb blog!
# Wow that was strange. I just wrote an very long comment but after I clicked submit my comment didn't appear. Grrrr... well I'm not writing all that over again. Regardless, just wanted to say superb blog!
2021/11/12 10:56 by
Wow that was strange. I just wrote an very long comment but after
I clicked submit my comment didn't appear. Grrrr... well I'm not writing all
that over again. Regardless, just wanted to say superb blog!
# Wow that was strange. I just wrote an very long comment but after I clicked submit my comment didn't appear. Grrrr... well I'm not writing all that over again. Regardless, just wanted to say superb blog!
2021/11/12 10:57 by
Wow that was strange. I just wrote an very long comment but after
I clicked submit my comment didn't appear. Grrrr... well I'm not writing all
that over again. Regardless, just wanted to say superb blog!
# vixshkibafdg
2021/11/29 15:27 by
# phzhhubzyrtq
2021/12/03 7:22 by
# For latest information you have to pay a visit the web and on web I found this web page as a best web page for newest updates.
2022/01/09 16:05 by
For latest information you have to pay a visit the web and on web I found this web page as
a best web page for newest updates.
# doxycycline 100mg tablets https://doxycyline1st.com/
buy cheap doxycycline online
2022/02/26 9:21 by
doxycycline 100mg tablets
https://doxycyline1st.com/
buy cheap doxycycline online
# clomid cost https://clomiden.fun/
2022/04/12 12:37 by
# prednisone pill prices https://prednisoneus.shop/
2022/04/16 22:31 by
# kawapyhjrmnd
2022/05/08 17:47 by
# xiosgyfqtpzw
2022/05/22 14:40 by
erythromycin ophthalmic ointment side effects
https://erythromycinn.com/#
# fnejuccwvkxd
2022/06/02 16:26 by
# furosemida 40 mg https://buylasix.icu/
lasix 100mg
2022/06/24 16:50 by
furosemida 40 mg
https://buylasix.icu/
lasix 100mg
# cheap clomid https://clomidonline.icu/
2022/07/08 13:17 by
# ed meds online without doctor prescription: https://medrxfast.com/
2022/08/03 18:48 by
ed meds online without doctor prescription:
https://medrxfast.com/
# prednisone brand name https://deltasone.icu/
order prednisone from canada
2022/08/22 9:25 by
prednisone brand name
https://deltasone.icu/
order prednisone from canada
# ed pills comparison https://ed-pills.xyz/
best non prescription ed pills
2022/09/15 18:56 by
ed pills comparison
https://ed-pills.xyz/
best non prescription ed pills
# top ed pills https://ed-pills.xyz/
generic ed pills
2022/09/16 7:16 by
top ed pills
https://ed-pills.xyz/
generic ed pills
# best ed pills online https://ed-pills.xyz/
best erection pills
2022/09/16 19:21 by
best ed pills online
https://ed-pills.xyz/
best erection pills