MonoMac Events - NSTable String Color Change

I am trying to change the color of a row in an NSTableView by subscribing to the WillDisplayCell event. Firstly, this event never rises. Secondly, the fields in NSTableView can no longer be selected, so the functionality is broken. The same behavior is observed for the SelectionChanged event, which does not work.

//NSTableView table
table.SelectionDidChange += SelectionChanged;
table.WillDisplayCell += WillDisplay;

How to make these events work?

Thank!

+3
source share
2 answers

Not sure if you solved it or not, but for someone else who comes across this, the solution is to add an observer, similar to the example of tableview, i.e.

arrayController.AddObserver(this,new NSString("selectionIndexes"),NSKeyValueObservingOptions.New,IntPtr.Zero);

Then override the observation method.

public override void ObserveValue (NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context)
{
...
}

This works, but the NSTableviewBinding example uses a different method, but this did not work for me.

+1

AwakeFromNib, ,

NSNotificationCenter.DefaultCenter.AddObserver (this, new Selector ("selectionChanged"), "NSTableViewSelectionDidChangeNotification", yourTableView);

[Export("selectionChanged")]
public void SelectionDidChangeNotification(NSObject o){
    ...
}
0

All Articles