Bug 8679 - NSTableView fails to render when subscribing to events that internally assign Delegate
Summary: NSTableView fails to render when subscribing to events that internally assign...
Status: CLOSED FIXED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: Master
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: 2.0.x
Assignee: Chris Hamons
URL:
Depends on:
Blocks:
 
Reported: 2012-11-29 17:48 UTC by Aaron Oneal
Modified: 2015-03-04 13:56 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Example project that repros (42.80 KB, application/zip)
2012-11-29 18:30 UTC, Aaron Oneal
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
CLOSED FIXED

Description Aaron Oneal 2012-11-29 17:48:11 UTC
From the mailing list.

We discovered that subscribing to any event on NSTableView internally sets Delegate to an auto-generated delegate which is not overriding the base implementation in a way that can render a data source by default.

However, subclassing and overriding instead of subscribing to the same event does work.

// WORKS (table is populated with data)
...
        tblTabella.Delegate = new MyTableViewDelegate();
...
        class MyTableViewDelegate : NSTableViewDelegate {
            public override void DidClickTableColumn (NSTableView tableView, NSTableColumn tableColumn)
            {
                Console.Out.WriteLine("Clicked table column");
            }
        }

// FAILS (table shows no cells)
        tblTabella.DidClickTableColumn += HandleDidClickTableColumn;


---
Robert Verdes - November 29, 2012 2:53 AM
I have a NSTableView with a Custom NSTableViewDataSource;
The TableView is cell based view
the problem i have is that when i try to handle this event
tblTabella.DidClickTableColumn += HandleDidClickTableColumn;
my data doesn't show anymore
It just enter GetRowCount but doesn't enter anymore in GetObjectValue
When i comment the row //tblTabella.DidClickTableColumn +=
HandleDidClickTableColumn; the data is shown
but i need to handle that event to be able to sort data based on the column
the user clicked
Is there any other way of doing it?
http://hosssting.altervista.org/Archivio.zip
Comment 1 Aaron Oneal 2012-11-29 18:30:13 UTC
Created attachment 3031 [details]
Example project that repros
Comment 2 Chris Hamons 2015-02-18 12:43:05 UTC
I think this is fixed in master / 2491f2f734e3052aabbfa9ac76c60ec8e23d7748 and
should be in XM 2.0 (this summer).

If so, this is fixed for the Unified Xamarin.Mac API. The change was
invasive / possibly breaking enough that we are making zero changes for
Classic.

Events on base and derived classes should now not stomp each other. We are not
supporting using both the c# events and delegate at the same time. If you try
this in Unified, we will throw an exception (since one of them won't be
called).

However, the example attached crashes due to incorrect threading (using UI bits on non ui threads) so I can't test it.
Comment 3 Rajneesh Kumar 2015-03-04 13:51:59 UTC
We are trying to verify this issue but As per comment 2 

>However, the example attached crashes due to incorrect threading (using UI bits on non ui threads) so I 
>can't test it.


Is there any other way to reproduce this issue ? So that we can  verify it efficiently.

Thanks
Comment 4 Chris Hamons 2015-03-04 13:56:31 UTC
@Rajneesh - I had not way to reproduce it, so I've got nothing to give you. The bug is 3 years old with no reply from the poster.

Thanks though.