Wpf DATAGRID未被选中 [英] Wpf DATAGRID was not getting selected

查看:134
本文介绍了Wpf DATAGRID未被选中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了提到的代码。当我试图选择一行时,它没有被选中。请告诉我我犯的错误。



< DataGrid Name =DG_FollowUpAutoGenerateColumns =FalseSelectionMode =SingleSelectedIndex =0Horizo​​ntalAlignment = StretchVerticalAlignment =StretchGrid.Column =0Grid.Row =01BorderBrush =BlackBorderThickness =0.5LoadingRow =DG_FollowUp_LoadingRowIsEnabled =TrueCanUserAddRows =false>

< datagrid.columns>

< DataGridTextColumn Binding ={Binding EntryID}Header =Entry IDWidth =75>

< datagridtextcolumn.elementstyle>



& lt; Setter Property =Horizo​​ntalAlignmentValue ='Center'/>







< DataGridTextColumn Binding ={Binding [TicketID / Subject ]}Header =TicketID / SubjectWidth =330CanUserSort =False/>

< DataGridTextColumn Binding ={Binding [AddDate]}Header =Start Date Width =90CanUserSort =False>

< DataGridTextColumn Binding ={Binding [Status]}Header =StatusWidth =130CanUserSort =False>

< DataGridTextColumn Binding ={Binding [OwnerShip]}Header =OwnershipWidth =130CanUserSort =False>

< DataGridTextColumn Binding ={Binding [Comments]}Header =CommentsWidth =300CanUserSort =False>

< DataGridTextColumn Binding ={Binding [SLA DATE]}Header = SLA DateWidth =90CanUserSort =False>

< DataGridCheckBoxColumn Header =Strike1Width =70CanUserSort =False>

< DataGridCheckBoxColumn Header =Strike2Width =70CanUserSort =Fals e>

< DataGridCheckBoxColumn Header =Strike3Width =70CanUserSort =False>









我通过从SQLDB读取数据绑定到上面的网格。



我尝试了什么:



i尝试使用IsEnabled =true,Selectionmode =Single以及给出selectedIndex = 0,它们都没有工作。

I used the blow mentioned code. When i am trying to select a row, its not getting selected. Please let me know the mistake i did.

<DataGrid Name="DG_FollowUp" AutoGenerateColumns="False" SelectionMode="Single" SelectedIndex="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="0" Grid.Row="01" BorderBrush="Black" BorderThickness="0.5" LoadingRow="DG_FollowUp_LoadingRow" IsEnabled="True" CanUserAddRows="false">
<datagrid.columns>
<DataGridTextColumn Binding="{Binding EntryID}" Header="Entry ID" Width="75">
<datagridtextcolumn.elementstyle>

&lt;Setter Property="HorizontalAlignment" Value='Center'/>



<DataGridTextColumn Binding="{Binding [TicketID/Subject]}" Header="TicketID/Subject" Width="330" CanUserSort="False"/>
<DataGridTextColumn Binding="{Binding [AddDate]}" Header="Start Date" Width="90" CanUserSort="False">
<DataGridTextColumn Binding="{Binding [Status]}" Header="Status" Width="130" CanUserSort="False">
<DataGridTextColumn Binding="{Binding [OwnerShip]}" Header="Ownership" Width="130" CanUserSort="False">
<DataGridTextColumn Binding="{Binding [Comments]}" Header="Comments" Width="300" CanUserSort="False">
<DataGridTextColumn Binding="{Binding [SLA DATE]}" Header="SLA Date" Width="90" CanUserSort="False">
<DataGridCheckBoxColumn Header="Strike1" Width="70" CanUserSort="False">
<DataGridCheckBoxColumn Header="Strike2" Width="70" CanUserSort="False">
<DataGridCheckBoxColumn Header="Strike3" Width="70" CanUserSort="False">




I am binding data to the above grid by reading from SQLDB.

What I have tried:

i tried using IsEnabled= "true", Selectionmode="Single" and also with giving selectedIndex=0, None of them were working.

推荐答案

SelectionChanged 添加事件处理程序,并在事件中设置断点处理方法。



运行应用程序,然后选择一个项目。如果点击断点,则正在选择该项目。如果是这种情况,请尝试在事件处理程序中添加对 UpdateLayout()的调用。
Add an event handler for SelectionChanged, and set a breakpoint in the event handler method.

Run the app, and select an item. If the breakpoint is hit, the item is being selected. If this is the case, try adding a call to UpdateLayout() in the event handler.


这篇关于Wpf DATAGRID未被选中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆