使用按钮将项目数据网格向下移动 [英] move item datagrid down up with button
问题描述
hi,iam是wpf的新功能. iam了解了datagrid控制,但是仍然混淆了如何使用事件进行上下移动,这是我的代码,谢谢
iam new in wpf. iam learn about datagrid control but still confuse how to use event for move up,down and ontop,this my code,thank you
XAML
< Grid>
< DataGrid x:Name ="datagrid"; HorizontalAlignment =左"保证金="56,23,0,0&"; VerticalAlignment =顶部"高度="215".宽度="336"/
<按钮x:Name ="btnup"内容=上" HorizontalAlignment =左"保证金="411,76,0,0&". VerticalAlignment =顶部"宽度="75". RenderTransformOrigin ="2.332,-8.752"/>
<按钮x:Name ="btndown";内容=下" HorizontalAlignment =左"保证金="411,98,0,0&"; VerticalAlignment =顶部"宽度="75"/
<按钮x:NAME ="bttop"内容=最高". HorizontalAlignment =左"保证金="411,54,0,0&" VerticalAlignment =顶部"宽度="75"/
</Grid>
<Grid>
<DataGrid x:Name="datagrid" HorizontalAlignment="Left" Margin="56,23,0,0" VerticalAlignment="Top" Height="215" Width="336"/>
<Button x:Name="btnup" Content="Up" HorizontalAlignment="Left" Margin="411,76,0,0" VerticalAlignment="Top" Width="75" RenderTransformOrigin="2.332,-8.752"/>
<Button x:Name="btndown" Content="Down" HorizontalAlignment="Left" Margin="411,98,0,0" VerticalAlignment="Top" Width="75"/>
<Button x:NAME="bttop" Content="top" HorizontalAlignment="Left" Margin="411,54,0,0" VerticalAlignment="Top" Width="75"/>
</Grid>
隐藏代码:
推荐答案
我不遵循您的尝试.
I don't follow what you are trying to do.
如果要滚动数据网格,那为什么不只使用scrollviewer?
If you want to scroll the datagrid then why would you not just use the scrollviewer?
如果要更改所选项目,则可以使用键盘上的向上/向下箭头进行操作.
If you want to change the selected item then the up down arrows on the keyboard do that.
.
几乎所有使用WPF的商业开发团队都使用MVVM模式.
Almost all commercial development teams who work with WPF use the MVVM pattern.
类似地,VB现在在商业上非常罕见,并且大多数团队都已转移到C#.
Similarly, VB is now pretty rare commercialy and most teams have moved to C#.
如果您的目的是学习商业工作,那么您可能要同时考虑两者.
If your purpose is to learn for commercial work then you might want to consider both.
这篇关于使用按钮将项目数据网格向下移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!