I'm using WPF and found that MVVM is most commonly used with WPF, encouraging to move the presentation logic into ViewModel and keep the code-behind at minimum.
However after some time I found myself putting more logic into view and doing these kind of stuff in view (XAML):
1 - Constructing string from multiple elements:
<TextBlock>
<Run Text="{Binding Prop1}" />
<!--<Run Combined with string.Format />-->
<Run Text="," />
<Run Text="{Binding Prop2}" />
</TextBlock>
2 - Moving conditional logic into data triggers:
<TextBox>
<TextBox.Resources>
<Style TargetType="TextBox">
<Style.Triggers>
<DataTrigger Binding="{Binding SomeProperty}" Value="value1">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
<DataTrigger Binding="{Binding SomeProperty}" Value="value2">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBox.Resources>
</TextBox>
3 - Using ContentControl combined with multiple data templates for different type contents:
<UserControl.Resources>
<DataTemplate x:Key="Template1" >
<ContentControl HorizontalContentAlignment="Stretch" Content="{Binding Item}">
<ContentControl.Resources>
<Style TargetType="ContentControl">
<Style.Triggers>
<DataTrigger Binding="{Binding HasAnyItem}" Value="True">
<Setter Property="ContentTemplate" Value="{DynamicResource Template2}" />
</DataTrigger>
<DataTrigger Binding="{Binding HasAnyItem}" Value="False">
<Setter Property="ContentTemplate" Value="{DynamicResource Template1}" />
</DataTrigger>
</Style.Triggers>
</Style>
</ContentControl.Resources>
</ContentControl>
</DataTemplate>
<DataTemplate x:Key="Template2" >
...
</DataTemplate>
<UserControl.Resources>
...
<ContentControl ContentTemplate="{StaticResource Template1}" Content="{Binding}"/>
and this list continues, but I assume that you get the general idea of what kind of stuff I'm talking about. I'm aware that some of these features are somehow the beauty of WPF.
But when it comes to maintainability and flexibility, Is there a better way of logic handling? Does it make my UI more than enough smart, which was an anti-pattern in the windows form days?