我正在尝试更改wpf中DataGrid的DataGridTemplateColumn中按钮的visibility属性和content属性。
XAML
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Name="btnViewTrans" Height="23" Width="75" Visibility="Hidden" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
VB
Private Sub grid1_LoadingRow(sender As System.Object, e As System.Windows.Controls.DataGridRowEventArgs) Handles grdPermits.LoadingRow
If not strValue="" Then
Dim btnViewTransaction As New Button
btnViewTransaction = DirectCast(e.Row.FindName("btnViewTrans"), Button)
btnViewTransaction.Visibility = Windows.Visibility.Visible
End If
End Sub
我没有使用MVVM。当我使用上面的方法时,它返回Null Reference错误。