I would like to, based on state, display one or the other control assigned to a grid’s cell, such as:
<Button x:Name="btnBla" Grid.Row=42 Grid.Column=7></Button>
<TextBlock x:Name="txtblockOh" Grid.Row=42 Grid.Column=7 IsEnabled="false"></TextBlock>
…and then in the code-behind:
btnBla.IsEnabled = someBool;
txtblockOh.IsEnabled = ! btnBla.IsEnabled;
Is this the preferred method to accomplish this?
if you want to “Show” one at a time as your question states, you should change the
Visibilityproperty insted of the IsEnabled.You CAN do it in code, although I always recommend against manipulating UI elements in code (be it WPF, Silverlight or WinRT), all XAML-based technologies are much friendlier if you use the MVVM way of thinking.