View Issue Details

IDProjectCategoryView StatusLast Update
0001337NoesisGUIC# SDKpublic2023-03-27 12:14
ReporterDjekke Assigned Tosfernandez  
PrioritynormalSeverityminor 
Status feedbackResolutionopen 
Product Version3.0 
Target Version3.2 
Summary0001337: Error: Cannot implicitly convert type 'Noesis.Binding' to 'Noesis.BindingExpressionBase'
Description

Issue occurred, when I tried to create a simple converter for dynamic creation
of ListView columns from List<string>.

DisplayMemberBinding = new Binding("[" + column + "]")

Steps to Reproduce:
public object Convert(object value, System.Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
if (value is List<string> config)
{
var grdiView = new GridView();
foreach (string column in config)
{
grdiView.Columns.Add(
new GridViewColumn
{
Header = column,
DisplayMemberBinding = new Binding("[" + column + "]")
});
}
return grdiView;
}
return Binding.DoNothing;
}

PlatformAny

Activities

sfernandez

sfernandez

2018-11-22 13:50

manager   ~0005319

In Noesis DisplayMemberBinding contains a BindingExpression, so you would need to do this:

public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is List<string> config)
{
var gridView = new GridView();
foreach (string column in config)
{
GridViewColumn col = new GridViewColumn { Header = column});
BindingOperations.SetBinding(col, GridViewColumn.ColumnProperty, new Binding("[" + column + "]"));
gridView.Columns.Add(col);
}
return gridView;
}
return Binding.DoNothing;
}

We will investigate how to expose the type of that property correctly as a Binding object for a future release.

Djekke

Djekke

2021-01-19 13:57

reporter   ~0006962

Sorry for late response.
After creating this report I found a workaround for my case that uses entirely different approach and forgot about it.
Sadly, later I encountered this problem from different angle, but at that time I found solution on forum https://www.noesisengine.com/forums/viewtopic.php?t=1868
But now that solution doesn't work anymore too.
So, how am I supposed to dynamically create binding for DisplayMemberBinding property of GridViewColumn?

sfernandez

sfernandez

2021-01-19 14:18

manager   ~0006963

Last edited: 2021-01-19 14:19

The code will look like this:


public class ProvideValueTarget : IServiceProvider, IProvideValueTarget
{
public object TargetObject { get; set; }
public object TargetProperty { get; set; }

public object GetService(System.Type serviceType)
{
if (serviceType == typeof(IProvideValueTarget)) return this;
return null;
}
}

void UpdateColumnBinding(GridViewColumn column, string path)
{
Binding binding = new Binding(path);
column.DisplayMemberBinding = (BindingExpression)binding.ProvideValue(new ProvideValueTarget { TargetObject = null, TargetProperty = null });
}

Issue History

Date Modified Username Field Change
2018-10-30 13:13 admin New Issue
2018-10-30 13:13 admin Reporter admin => Djekke
2018-10-30 13:13 admin Assigned To => sfernandez
2018-10-30 13:13 admin Status new => assigned
2018-11-01 02:14 jsantos View Status public => private
2018-11-22 13:50 sfernandez Status assigned => feedback
2018-11-22 13:50 sfernandez Note Added: 0005319
2021-01-19 13:57 Djekke Note Added: 0006962
2021-01-19 13:57 Djekke Status feedback => assigned
2021-01-19 14:18 sfernandez Status assigned => feedback
2021-01-19 14:18 sfernandez Note Added: 0006963
2021-01-19 14:19 sfernandez Note Edited: 0006963
2022-07-28 12:05 sfernandez Product Version => 3.0
2022-07-28 12:05 sfernandez Target Version => 3.2.0
2022-07-28 12:05 sfernandez View Status private => public
2022-07-28 12:05 sfernandez Platform => Any
2023-03-27 12:14 jsantos Target Version 3.2.0 => 3.2