WPF: Making Objects Invisible

This is not as easy as it might have been. There is no Visible property on ModelVisual3D or GeometryModel3D. Approaches considered in this discussion on the Microsoft site include making material brushes transparent or having a transform on the object moving it out of the way.

Fiddling with brushes leads to problems. First, base Material class does not expose the Brush property, so you must hunt for a concrete material such as DiffuseMaterial to get the actual brush. Second, the poster reports issues with objects other than the intended object getting partially invisible, etc.

The approach with transforms “to nowhere” seems more attractive, but it kinda reminds me of the days when people put windows at “large” negative coordinates (say -1000,-1000) to make them “invisible”. It worked fine for a while, but turned out quite ugly when 1200×1024 double-monitor setups became common. If you make your right monitor a primary, the left monitor gets negative coordinates, and you suddenly see all those windows crowded in the bottom of your screen.

Posted in

Leave a Reply

Your email address will not be published. Required fields are marked *