1
\$\begingroup\$

I made a simple data entry application in WPF MVVM and was just hoping for some input as I am pretty new to WPF . I have done the same application using winforms. Now I have recreated the same application using WPF.

I have understood how to write wpf based application, how to use command and other aspects of c# development in wpf. But the thing I don't understand is XAML UI devleopment.

I would appreciate any type of input for XAML. I do feel that I may have problems specifically in how I'm using the panels and allocating space with application using margins. enter image description here

I have divided the tool into three stack using dockpanel and pasted the componets inside those panels.

StackPanel 1:

    <TabControl SelectedIndex="{Binding selectedIndex}" Grid.Row="0" Height="478" Margin="0,43,-8,-15" x:Name="tabControl1" Width="auto">
        <TabItem Header="Claim Information" x:Name="tabItem1">
            <UniformGrid Columns="1" Margin="-6,0,55.291,8.027" Width="1144">
                <DockPanel Margin="-0,0,-20,0" VerticalAlignment="Top" Width="1161.998" Height="55">
                    <StackPanel Margin="10,5,35,5" Orientation="Horizontal" DockPanel.Dock="Top"  Height="51" Width="1138">
                        <Label Margin="1,14,708.962,0" x:Name="label11" HorizontalAlignment="Left" VerticalAlignment="Top" Width="44" Height="28" Content="Date"/>
                        <TextBox IsEnabled="{Binding Isdisabled}"  Margin="-700,1,708.962,0" HorizontalAlignment="Right" VerticalAlignment="Center" x:Name="txtBoxDate" Width="69" Height="19" Text="{Binding DateTimeArgument, Mode=TwoWay, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
                        <Label Margin="-700,1,708.962,0" x:Name="username" HorizontalAlignment="Left" Width="68" Height="28" Content="User Name"/>
                        <TextBox IsEnabled="{Binding Isdisabled}" x:Name="usernameTextbox" Margin="-700,1,708.962,0" Width="99" Height="19" Text="{Binding UserNameArgument, Mode=TwoWay, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
                        <Button IsEnabled="{Binding IsStartButtonEnabled}" Width="79"  Height="19.277" Margin="-700,1,708.962,0" x:Name="startbutton" Command="{Binding AddNew}" Content="Start Time"/>
                        <Label Width="61" Height="24" Margin="-700,1,708.962,0" x:Name="StartTimeLabel" HorizontalAlignment="Left" Content="Start Time"/>
                        <TextBox IsEnabled="{Binding Isdisabled}" x:Name="StarttimeTextbox" Width="71"  Height="19.277" Margin="-700,1,708.962,0" Text="{Binding StartTimerArgument, Mode=TwoWay, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
                        <Label Width="44" Height="24" Margin="-700,14,708.962,13" x:Name="Timer1" HorizontalAlignment="Left" Content="Timer"/>
                        <TextBox IsEnabled="{Binding Isdisabled}" x:Name="Timer" Width="60"  Height="19.277" Margin="-700,1,708.962,0" Text="{Binding TimerArgument, Mode=TwoWay, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
                        <Label Width="60" Height="24" Margin="-700,1,708.962,0" x:Name="endtimer" HorizontalAlignment="Left" Content="End Time"/>
                        <TextBox IsEnabled="{Binding Isdisabled}" x:Name="EndTimer" Width="60"  Height="19.277" Margin="-700,1,710.962,0" Text="{Binding EndTimerArgument, Mode=TwoWay, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
                        <Label Width="65" Height="24" Margin="-710,1,-238.962,0" x:Name="TotalTimer" HorizontalAlignment="Left" Content="Total Time"/>
                        <TextBox IsEnabled="{Binding Isdisabled}" x:Name="TotalTimeTaken" Width="86"   Height="19.277" Margin="-635,1,708.962,0" Text="{Binding TotalTimerArgument, Mode=TwoWay, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
                        <Label Width="52" Height="24" Margin="-700,1,-238.962,0" x:Name="labelFrportal" HorizontalAlignment="Left" Content="Fr Portal"/>
                        <TextBox IsEnabled="{Binding Isdisabled}" x:Name="txtboxFrportal" Width="62" Height="19.277" Margin="-890,15,338,12" Text="{Binding FRPortalTime, Mode=TwoWay}" />

                    </StackPanel>

                </DockPanel>  

stackpanel 2 :

                <DockPanel VerticalAlignment="Top" Margin="1,-80,0,0" HorizontalAlignment="Left" Width="1075" Height="53">
                    <StackPanel Margin="1,0,-30,0" Orientation="Horizontal" DockPanel.Dock="Top" Width="1077" Height="53">
                        <Label Width="49" Height="23.277" HorizontalAlignment="Left" Margin="1,14,30,0" VerticalAlignment="Top" Content="AuditID"/>
                        <TextBox x:Name="txtboxAuditId" IsEnabled="{Binding IsEnabled}" Width="108" Height="19.277" HorizontalAlignment="Left" Margin="-20,14,708.962,0" VerticalAlignment="Top" Text="{Binding GetRowData.AuditId}" />
                                                    <Label Margin="-700,1,-228.962,0"  x:Name="label111" HorizontalAlignment="Left" Width="77" Height="28" Content="ClaimNumber"/>
                        <TextBox IsEnabled="{Binding IsEnabled}" HorizontalAlignment="Left" Width="113" Height="19.277"  Margin="-620,1,-228.962,0"  x:Name="txtBoxDate1" Text="{Binding GetRowData.Claimnumber}"/>
                        <Label Margin="-500,1,-228.962,0"  x:Name="Linesforcpt" HorizontalAlignment="Left" Width="77" Height="28" Content="CPT Lines"/>
                        <TextBox IsEnabled="{Binding IsEnabled}" HorizontalAlignment="Left" Width="113" Height="19.277"  Margin="-420,1,-228.962,0"  x:Name="TxtboxLinesforcpt" Text="{Binding CPTLines, Mode=TwoWay, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
                        <Label Margin="-290,13,5.962,12"  x:Name="lblcommnets" HorizontalAlignment="Left" Width="67" Height="28" Content="Comments"/>
                        <TextBox IsEnabled="{Binding IsEnabled}" HorizontalAlignment="Left" Width="113" Height="19.277"  Margin="-200,-1,-218.962,0"  x:Name="txtboxComments" Text="{Binding Comments, Mode=TwoWay, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
                        <Label Margin="-70,13,-228.962,12" x:Name="lblFInalstatus" HorizontalAlignment="Left" Width="72" Height="28" Content="Final Status"/>
                        <ComboBox ItemsSource="{Binding Source={StaticResource MyEnums}}" SelectedItem="{Binding CurrentItem, Mode=TwoWay}"  HorizontalAlignment="Left" VerticalAlignment="Center" IsEnabled="{Binding IsEnabled}"  Width="113" Height="19.277"  Margin="10,1,-228.962,0"  x:Name="cmbboxFinalstatus"/>
                        <Button Content="End Timer"  Command="{Binding stop}" Margin="90,1,-269.962,0"  Width="66" Height="19.277">
                            <Button.Style>
                                <Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">

                                    <Setter Property="IsEnabled" Value="True" />
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding CurrentItem}" Value="{x:Null}">
                                            <Setter Property="IsEnabled" Value="False" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </Button.Style>
                        </Button>
                    </StackPanel>
                </DockPanel>

stack 3:

                <DockPanel  Margin="1,-225,0,0"  Width="1075" Height="193">
                    <StackPanel Margin="1,0,0,0" Orientation="Horizontal" DockPanel.Dock="Top" Width="1077" Height="293">
                        <Button Command="{Binding Submitbutton}"  Margin="500,-19,0,171" Width="70" Height="20"  VerticalAlignment="Center" IsEnabled="{Binding IsEnabledSubmit}" Content="Submit"/>

                    </StackPanel>
                </DockPanel>
            </UniformGrid>
        </TabItem>

Namespace :

   xmlns:vm="clr-namespace:Activity_Tracker_Coding_WPF.ViewModel" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Converter="clr-namespace:Activity_Tracker_Coding_WPF.ViewModel"

xmlns:sys="clr-namespace:System;assembly=mscorlib"
     xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="Activity_Tracker_Coding_WPF.Window1"
    Title="Activty Tracker Application" Height="506" Width="1177" Background="LightGray">
\$\endgroup\$
  • 1
    \$\begingroup\$ Welcome to CR! It could be a good idea to include the ViewModel class, and keep the xaml markup together in the same block if it's all in the same file. \$\endgroup\$ – Mathieu Guindon Mar 11 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.