C
C#2y ago
Kippachu

❔ WPF Date entry Forms MVVM

Hello, I don't understand in WPF when I should use MVVM and when I shouldn't. For example, i'm loading a data entry forms into a region that i've hard coded in XAML :
<UserControl [...]
<Grid Grid.Row="3" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ComboBox Grid.Column="0" Style="{StaticResource MaterialDesignOutlinedComboBox}" materialDesign:TextFieldAssist.HasClearButton="True" Margin="8" materialDesign:HintAssist.Hint="Gender" ItemsSource="{Binding Genders}" SelectedItem="{Binding SelectedGender}" />
<TextBox Grid.Column="1" Style="{StaticResource MaterialDesignOutlinedTextBox}" materialDesign:TextFieldAssist.HasClearButton="True" Margin="8" materialDesign:HintAssist.Hint="First Name and Last Name" Text="{Binding FullName}" />
</Grid>

<Grid Grid.Row="4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" materialDesign:TextFieldAssist.HasClearButton="True" Style="{StaticResource MaterialDesignOutlinedTextBox}" Margin="8" materialDesign:HintAssist.Hint="Length" Text="{Binding Length}" />
<TextBox Grid.Column="1" materialDesign:TextFieldAssist.HasClearButton="True" Style="{StaticResource MaterialDesignOutlinedTextBox}" Margin="8" materialDesign:HintAssist.Hint="Day" Text="{Binding Day}" />
</Grid>

<TextBox Grid.Row="5" materialDesign:TextFieldAssist.HasClearButton="True" Style="{StaticResource MaterialDesignOutlinedTextBox}" Margin="8" materialDesign:HintAssist.Hint="Work To Do" Text="{Binding WorkToDo}" />
</Grid>

</UserControl>
<UserControl [...]
<Grid Grid.Row="3" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ComboBox Grid.Column="0" Style="{StaticResource MaterialDesignOutlinedComboBox}" materialDesign:TextFieldAssist.HasClearButton="True" Margin="8" materialDesign:HintAssist.Hint="Gender" ItemsSource="{Binding Genders}" SelectedItem="{Binding SelectedGender}" />
<TextBox Grid.Column="1" Style="{StaticResource MaterialDesignOutlinedTextBox}" materialDesign:TextFieldAssist.HasClearButton="True" Margin="8" materialDesign:HintAssist.Hint="First Name and Last Name" Text="{Binding FullName}" />
</Grid>

<Grid Grid.Row="4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" materialDesign:TextFieldAssist.HasClearButton="True" Style="{StaticResource MaterialDesignOutlinedTextBox}" Margin="8" materialDesign:HintAssist.Hint="Length" Text="{Binding Length}" />
<TextBox Grid.Column="1" materialDesign:TextFieldAssist.HasClearButton="True" Style="{StaticResource MaterialDesignOutlinedTextBox}" Margin="8" materialDesign:HintAssist.Hint="Day" Text="{Binding Day}" />
</Grid>

<TextBox Grid.Row="5" materialDesign:TextFieldAssist.HasClearButton="True" Style="{StaticResource MaterialDesignOutlinedTextBox}" Margin="8" materialDesign:HintAssist.Hint="Work To Do" Text="{Binding WorkToDo}" />
</Grid>

</UserControl>
Would it be better to use an ItemsControl and define the elements in ViewModel ? Thanks in advance
1 Reply
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server