I have a ListView with a custom ListCellFactory. In my CustomListCell implemenation I use setGraphic to set the list item graphic to a GridPane but I am not able not let the GridPane fill the whole width of the ListView. The following is a short version of my code:
class MyListCell extends ListCell<MyObject>
{
private final GridPane _myComponent;
public MyListCell()
{
...
setContentDisplay(ContentDisplay.GRAPHIC_ONLY); // does not help
//this.setPrefWidth(0); // does not help
myComponent.prefWidthProperty().bind(this.widthProperty()); // does not help
}
...
@Override
protected void updateItem(MyObject item, boolean empty)
{
...
setGraphic(_myComponent);
...
}
}
Even with the prefWidth bounding from another post my GridPane will not grow! No matter what combination of layout constraints I use it looks as follows:
The GridPane shall expand to the full width of the ListCell (I want to add a delete button at the buttom right corner). I'm getting crazy, please help!