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

Unable to cast Gtk.NodeView into other Classes. #267

Open
Mascasc opened this issue Mar 12, 2019 · 1 comment
Open

Unable to cast Gtk.NodeView into other Classes. #267

Mascasc opened this issue Mar 12, 2019 · 1 comment

Comments

@Mascasc
Copy link

Mascasc commented Mar 12, 2019

I have a function, as below, attached to a NodeView widget:

`protected void onSongSelected(object o, RowActivatedArgs args)
{
object selection = o;
}'

By using GetType() I have been able to verify that o (and thus selection also) is of type Gtk.NodeView().

However, I've been reading through this tutorial from Mono for working with Treeview and Nodeview Gtk# widgets: https://www.mono-project.com/docs/gui/gtksharp/widgets/nodeview-tutorial/

And, when I try object selection = (NodeSelection)o; I get an error saying that object o can not be cast into the class NodeSelection. I would like to be able to access other information associated with my node, and hoped to do so via the method illustrated in the guide. But I remain unable to change the class of variable o in any way.

Is there something I am doing incorrectly that is causing this problem?

@awittaker
Copy link

It looks like an old fixed bug has re-appeared (gtk-sharp2: 2.12.45-0)
https://bugzilla.xamarin.com/show_bug.cgi?id=51688

This workaround works for me...

using System.Reflection;
...
nodeview.NodeStore = nodestore;
typeof (NodeView).GetField ("store", BindingFlags.Instance | BindingFlags.NonPublic).SetValue (nodeview, nodestore);

See also #242 "Gtk.NodeView(NodeStore) constructor does not work (but NodeStore property does)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants