dotnet / dotnet/wpf

Two ways binding NullReferenceException

Open
#4,969 10 comments 0 reactions 0 assignees View on GitHub
:construction: work in progress
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

# Configuration

|Name|Version|
|:-:|:-:|
|dotnet tool| 5.0.302 |
|target framework| net452, net461, net472 |

# Problem

When I use background binding, provided `Path`, `Source` and set mode `TwoWay`, always throw NullReferenceException , but in net5.0 no exception, but how can i do when in NET Framework?

Whether i use `SetBinding` or `BindingOperations.SetBinding`.

# StackTrack

```
at MS.Internal.AvTrace.AntiFormat(String s)
```

1

# Code

```csharp
var q = new Binding();
q.Path = new PropertyPath("RotateTransform");
q.Source = obj.RotateTransformDesigner;
q.Mode = BindingMode.TwoWay;
Bd.SetBinding(Control.RenderTransformProperty, q);
BindingOperations.SetBinding(Bd, Control.RenderTransformProperty, q);//ERROR
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.