Closed clairernovotny closed 4 years ago
That is because the two RepositoryMetadata
instances are equal. Unfortunately for you, the class overrides equatability and compares only the Url, see https://github.com/NuGet/NuGet.Client/blob/f7e4a189c85fc6cfcc2d3f6b3d94079125adfe91/src/NuGet.Core/NuGet.Packaging/Core/RepositoryMetadata.cs#L68.
As far as WPF is concerned, the metadata hasn't changed and there is no binding to update.
But the whole data context hierarchy is updated? Shouldn't it refresh the bindings?
@nkolev92 why is RepositoryMetadata only comparing part of the data?
@clairernovotny The bindings refresh (if you put a breakpoint into EditablePackageMetadata.Repository
getter, it will hit as you open the new package), but the binding sees the value is the same as before so it doesn't bother updating the target.
Your options basically are:
RepositoryMetadata
, basically a view model (your best bet);The class is not sealed, so you could theoretically just inherit from it and wrap the value
in the property setter, with no change to your API.
Edit: or that :)
As this is by design (and the implied proposal to force-update all binding targets regardless of whether value has changed has significant performance implications and can introduce infinite loops), I assume this issue can be closed.
@nkolev92 why is RepositoryMetadata only comparing part of the data?
@clairernovotny that's a bug :(
https://github.com/NuGet/NuGet.Client/commit/0e4d1b598f350b3dc675018d539114d1328189ef
Created an issue: https://github.com/NuGet/Home/issues/9613
dotnet --info
) 5.0p4winver
) 19041Security issues and bugs should be reported privately, learn more via our responsible disclosure guidelines.
Problem description: A textblock within a data template isn't being updated correctly in some specific repro steps.
Actual behavior: Textbox displays old value
Evalutated expression also doesn't match datacontext
Expected behavior: Binding is correct
Minimal repro:
master
hub.com/NuGetPackageExplorer/NuGetPackageExplorerGrpc.Net.Client
. Select "all versions" and open 2.28. Note the Git Commit sha on the left.It's not clear what's going on -- each time a package is loaded, it's a new PackageViewModel at the MainWindow DataContext.