C
C#7mo ago
Janek

✅ Why I'm getting ArgumentException/System.Windows.Markup.XamlParseException exception?

Hey! I was refactoring another part of this project and some how this part of the application broke and it gives me this error:
System.Windows.Markup.XamlParseException: ''Failed to create a 'AutoGeneratingColumn' from the text 'dg_input_AutoGeneratingColumn'.' Line number '16' and line position '32'.'
ArgumentException: Cannot bind to the target method because its signature or security transparency is not compatible with that of the delegate type.
System.Windows.Markup.XamlParseException: ''Failed to create a 'AutoGeneratingColumn' from the text 'dg_input_AutoGeneratingColumn'.' Line number '16' and line position '32'.'
ArgumentException: Cannot bind to the target method because its signature or security transparency is not compatible with that of the delegate type.
Here is the code it reads. (I tried to debug to figure out what is wrong, but did not find out by my self..) So I had break point at public ManualInputWindows(..), next step was function InitializeComponent() call and from that it called CustomDataGrid() : base contructor. After that I got the error.
public partial class ManualInputWindow : Window
{
private DataTable _input;
public ManualInputWindow(DataTable input)
{
InitializeComponent();
...
public partial class ManualInputWindow : Window
{
private DataTable _input;
public ManualInputWindow(DataTable input)
{
InitializeComponent();
...
class CustomDataGrid : DataGrid
{
public CustomDataGrid() : base()
{
}
...
class CustomDataGrid : DataGrid
{
public CustomDataGrid() : base()
{
}
...
private void Dg_input_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
{
if (e.Column is DataGridTextColumn column)
{
((Binding)column.Binding).Converter = new StringEmpty_to_Null_Converter();
}
else if (e.Column is DataGridCheckBoxColumn column1)
{
if (_input.Columns[e.PropertyName].AllowDBNull)
{
column1.IsThreeState = true;
((Binding)column1.Binding).Converter = new NullToDBNullConverter();
}
}
}
private void Dg_input_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
{
if (e.Column is DataGridTextColumn column)
{
((Binding)column.Binding).Converter = new StringEmpty_to_Null_Converter();
}
else if (e.Column is DataGridCheckBoxColumn column1)
{
if (_input.Columns[e.PropertyName].AllowDBNull)
{
column1.IsThreeState = true;
((Binding)column1.Binding).Converter = new NullToDBNullConverter();
}
}
}
No description
1 Reply
Janek
JanekOP7mo ago
nvm, this was ridiculous.. I used ctrl+r to rename dg_input_AutoGeneratingColumn to correct form and it did not update it on xaml file.. I'm so stupid..
Want results from more Discord servers?
Add your server