Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReactiveUI Events doesn't seem to have an implementation of SelectionChanged for ListView #2791

Closed
Awsmolak opened this issue Jun 15, 2021 · 15 comments
Labels

Comments

@Awsmolak
Copy link
Contributor

Attempting to use the events on a listview to get the selected items.

In my viewmodel:

this.MyListView.Events().SelectionChanged
....

Does not work because Events() doesn't seem to have SelectionChanged implemented.

@Awsmolak Awsmolak added the bug label Jun 15, 2021
@glennawatson
Copy link
Contributor

glennawatson commented Jun 15, 2021

If you're in a position to you can try moving to our preferred mechanism now the source generator https://github.com/reactivemarbles/ObservableEvents#observable-event-generator

GitHub
Contribute to reactivemarbles/ObservableEvents development by creating an account on GitHub.

@Awsmolak
Copy link
Contributor Author

Not in a position at the moment. Going to go ahead and use Observable.FromEventPattern for the moment, if there truly is no event implementation yet. Like this (I was wondering if I had maybe missed something...)

I'll explore using the generator sometime down the line.

@glennawatson
Copy link
Contributor

When you are in a position it should be a straight swap over, no change in the syntax.

@Awsmolak
Copy link
Contributor Author

Awsmolak commented Jun 15, 2021

The event I'm trying to subscribe to is System.Controls.Listview. The readme only discusses using the generator on my classes. So how would I get it to generate the event for external assemblies like that?

@glennawatson
Copy link
Contributor

The generator will work for ListView automatically.

@Awsmolak
Copy link
Contributor Author

Gotcha!
I've added the package using the recommendation in the Readme, but I can't seem to reference ReactiveMarbles.ObservableEvents. My project is .NET 4.8 not .NET Core...

@glennawatson
Copy link
Contributor

What version of Visual Studio are you using?

@Awsmolak
Copy link
Contributor Author

2019 v16.9.4

@glennawatson
Copy link
Contributor

New enough to handle source generators although v16.10 is better.

Sometimes you might need to give the project a compile first.

@Awsmolak
Copy link
Contributor Author

Awsmolak commented Jun 15, 2021

I've tried rebuilding, reopening solution, installing from the package manager GUI instead of adding the packagereference to the .csproj. Nothing...

Updated VS to 16.10.2. Still getting:

error CS0246: The type or namespace name 'ReactiveMarbles' could not be found (are you missing a using directive or an assembly reference?)

@Awsmolak
Copy link
Contributor Author

Awsmolak commented Jun 16, 2021

No luck. Maybe there is something funky going on with Nuget?
One interesting thing I noticed is that if I add:

<PackageReference Include="ReactiveMarbles.ObservableEvents.SourceGenerator" Version="1.0.2" PrivateAssets="all" />

to my .csproj, the package manager GUI no longer sees any of my other packages, just that one.

But regardless of how I reference it in my project, the compiler will not pick it up.

@glennawatson
Copy link
Contributor

glennawatson commented Jun 16, 2021

If you want you can jump onto Slack I can probably maybe give you a bit more interactive help rather than in a issue.

https://www.reactiveui.net/slack

@drepamig
Copy link

drepamig commented Jul 20, 2021

I was having a similar issue as @Awsmolak. After some troubleshooting, I found a solution. See this issue. The key that helped me find the solution was the build failing in *_wpftmp.csproj vs the actual project's csproj.

The fix is simply to add <IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation> to the <PropertyGroup> section in your project's csproj file.

@glennawatson
Copy link
Contributor

Looks like there is a solution bsaed on @drepamig -- Thanks for the help.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants