How to Instantiate an entire XAML Grid object in C#? - c#

I'd like to instantiate an entire XAML Grid object in C#. My Grid object is a beast, it has 9 user-input fields, borders, labels and images.
I also want five instances of my Grid object, and I would like to instantiate them during run-time on the fly (with a press of a button). Is this possible? What is the best approach? Here is my Grid object...
<Grid Margin="2">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Grid.Row="1" Grid.Column="0" Grid.RowSpan="6" Grid.ColumnSpan="8" BorderBrush="Black" BorderThickness="1" CornerRadius="5">
<Label Grid.Row="1" Grid.RowSpan="3" Grid.Column="0" Grid.ColumnSpan="8" Background="#505050" ></Label>
</Border>
<TextBlock Grid.Row="0" Grid.Column="2" Grid.ColumnSpan="4" Text="TRANSFORM" TextAlignment="Center" FontSize="10" Foreground="#FD3777" FontFamily="./resources/#Pilsen"></TextBlock>
<TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="8" Text="Position" VerticalAlignment="Bottom" TextAlignment="Left" FontSize="10" Foreground="#FD3777" FontFamily="./resources/#Pilsen" Margin="2"></TextBlock>
<TextBlock Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="1" Text="x " VerticalAlignment="Bottom" TextAlignment="Right" FontSize="10" Foreground="#FD3777" FontFamily="./resources/#Pilsen"></TextBlock>
<TextBlock Grid.Row="1" Grid.Column="4" Grid.ColumnSpan="1" Text="y " VerticalAlignment="Bottom" TextAlignment="Right" FontSize="10" Foreground="#FD3777" FontFamily="./resources/#Pilsen"></TextBlock>
<TextBlock Grid.Row="1" Grid.Column="6" Grid.ColumnSpan="1" Text="z " VerticalAlignment="Bottom" TextAlignment="Right" FontSize="10" Foreground="#FD3777" FontFamily="./resources/#Pilsen"></TextBlock>
<TextBox x:Name ="transform_x" Grid.Row="1" Grid.Column="3" Grid.ColumnSpan="1" TextAlignment="Center" VerticalAlignment="Bottom" FontSize="10" Background="#707070" Foreground="Black" FontFamily="./resources/#Pilsen" Margin="2" ></TextBox>
<TextBox x:Name ="transform_y" Grid.Row="1" Grid.Column="5" Grid.ColumnSpan="1" TextAlignment="Center" VerticalAlignment="Bottom" FontSize="10" Background="#707070" Foreground="Black" FontFamily="./resources/#Pilsen" Margin="2" ></TextBox>
<TextBox x:Name ="transform_z" Grid.Row="1" Grid.Column="7" Grid.ColumnSpan="1" TextAlignment="Center" VerticalAlignment="Bottom" FontSize="10" Background="#707070" Foreground="Black" FontFamily="./resources/#Pilsen" Margin="2" ></TextBox>
<TextBlock Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="8" Text="Rotation" VerticalAlignment="Bottom" TextAlignment="Left" FontSize="10" Foreground="#FD3777" FontFamily="./resources/#Pilsen" Margin="2"></TextBlock>
<TextBlock Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="1" Text="x " VerticalAlignment="Bottom" TextAlignment="Right" FontSize="10" Foreground="#FD3777" FontFamily="./resources/#Pilsen"></TextBlock>
<TextBlock Grid.Row="2" Grid.Column="4" Grid.ColumnSpan="1" Text="y " VerticalAlignment="Bottom" TextAlignment="Right" FontSize="10" Foreground="#FD3777" FontFamily="./resources/#Pilsen"></TextBlock>
<TextBlock Grid.Row="2" Grid.Column="6" Grid.ColumnSpan="1" Text="z " VerticalAlignment="Bottom" TextAlignment="Right" FontSize="10" Foreground="#FD3777" FontFamily="./resources/#Pilsen"></TextBlock>
<TextBox x:Name ="rotation_x" Grid.Row="2" Grid.Column="3" Grid.ColumnSpan="1" TextAlignment="Center" VerticalAlignment="Bottom" FontSize="10" Background="#707070" Foreground="Black" FontFamily="./resources/#Pilsen" Margin="2"></TextBox>
<TextBox x:Name ="rotation_y" Grid.Row="2" Grid.Column="5" Grid.ColumnSpan="1" TextAlignment="Center" VerticalAlignment="Bottom" FontSize="10" Background="#707070" Foreground="Black" FontFamily="./resources/#Pilsen" Margin="2"></TextBox>
<TextBox x:Name ="rotation_z" Grid.Row="2" Grid.Column="7" Grid.ColumnSpan="1" TextAlignment="Center" VerticalAlignment="Bottom" FontSize="10" Background="#707070" Foreground="Black" FontFamily="./resources/#Pilsen" Margin="2"></TextBox>
<TextBlock Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="8" Text="Scale" VerticalAlignment="Bottom" TextAlignment="Left" FontSize="10" Foreground="#FD3777" FontFamily="./resources/#Pilsen" Margin="2"></TextBlock>
<TextBlock Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="1" Text="x " VerticalAlignment="Bottom" TextAlignment="Right" FontSize="10" Foreground="#FD3777" FontFamily="./resources/#Pilsen"></TextBlock>
<TextBlock Grid.Row="3" Grid.Column="4" Grid.ColumnSpan="1" Text="y " VerticalAlignment="Bottom" TextAlignment="Right" FontSize="10" Foreground="#FD3777" FontFamily="./resources/#Pilsen"></TextBlock>
<TextBlock Grid.Row="3" Grid.Column="6" Grid.ColumnSpan="1" Text="z " VerticalAlignment="Bottom" TextAlignment="Right" FontSize="10" Foreground="#FD3777" FontFamily="./resources/#Pilsen"></TextBlock>
<TextBox x:Name ="scale_x" Grid.Row="3" Grid.Column="3" Grid.ColumnSpan="1" TextAlignment="Center" VerticalAlignment="Bottom" FontSize="10" Background="#707070" Foreground="Black" FontFamily="./resources/#Pilsen" Margin="2"></TextBox>
<TextBox x:Name ="scale_y" Grid.Row="3" Grid.Column="5" Grid.ColumnSpan="1" TextAlignment="Center" VerticalAlignment="Bottom" FontSize="10" Background="#707070" Foreground="Black" FontFamily="./resources/#Pilsen" Margin="2"></TextBox>
<TextBox x:Name ="scale_z" Grid.Row="3" Grid.Column="7" Grid.ColumnSpan="1" TextAlignment="Center" VerticalAlignment="Bottom" FontSize="10" Background="#707070" Foreground="Black" FontFamily="./resources/#Pilsen" Margin="2"></TextBox>
</Grid>

Simply new up a Grid in code
Grid grid = new Grid() { Margin = new Thickness(2) };
and add elements to it eg.
grid.Children.Add(new Border());
TextBlock t = new TextBlock();
t.SetValue(Grid.RowProperty, 0);
t.SetValue(Grid.ColumnProperty, 2);
grid.Children.Add(t);
//etc...
Or you could add a UserControl item to your project and put your Grid inside its xaml. Then you can new up as many MyGridControl's as you want.

You can do the following:
create a UserControl containing your grid, say MyBeastGrid
in your destination form have a placeholder where those instantiated grids should be placed, say MyPlaceholder
add a button (or other triggering mechanism that should add the MyBeastGrid to MyPlaceholder)
in the button's Click event handler you simply call MyPlaceholder.Children.Add(new MyBeastGrid());
If you need to pass some parameters to MyBeastGrid, define some public properties there and either provide parameterised constructor or call your grid with new MyBeastGrid() { Property1 = value1, Property2 = value2 };
I suggest you use ScrollViewer to store your MyBeastGrid instances as it provides scrolling out of the box.

Related

Printing in UWP app - different layout on different devices

I've created printing solution for my XAML UWP MVVM application using example described on this link: https://xamlbrewer.wordpress.com/2016/10/25/a-recipe-for-printing-in-uwp-mvvm-apps/ (The source code is on the link: https://github.com/XamlBrewer/XamlBrewer.Uwp.PrintService )
Print preview that I get on my laptop is different than the one I get on the toughbook Panasonic CF-20. On the thoughbook layout gets messed up.
On the laptop (looks exactly the same on several laptops/PCs):
laptop_print
On the thoughbook:
thoughbook_print
My report page (page I use for preview/printing):
<Page
x:Class="WK.Drf.FrontOffice.App.UI.DossierHandling.HandoverPrintReport"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WK.Drf.FrontOffice.App.UI.DossierHandling"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<RichTextBlock Height="640" VerticalAlignment="Bottom">
<Paragraph TextAlignment="Left" Margin ="55,0,0,0">
<Run Text="Overdracht" FontSize="30" FontWeight="Bold" />
<LineBreak />
</Paragraph>
<Paragraph>
<InlineUIContainer>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="55"/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock TextWrapping="WrapWholeWords" FontWeight="Bold" Grid.Column="1" Grid.Row="0">RAV Kennemerland</TextBlock>
<TextBlock Text="{Binding AmbulanceNumber}" TextWrapping="WrapWholeWords" Grid.Column="1" Grid.Row="1" />
<TextBlock Text="{Binding ParamedicCode}" TextWrapping="WrapWholeWords" Grid.Column="1" Grid.Row="2" />
<TextBlock Text="{Binding DriverCode}" TextWrapping="WrapWholeWords" Grid.Column="1" Grid.Row="3" />
<TextBlock Text="{Binding ThirdPersonCode}" TextWrapping="WrapWholeWords" Grid.Column="1" Grid.Row="4" />
<TextBlock Text="{Binding PatientName}" TextWrapping="WrapWholeWords" FontWeight="Bold" Grid.Column="2" Grid.Row="0" />
<TextBlock Text="{Binding PatientDateOfBirth}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="1" />
<TextBlock Text="{Binding PatientAddress1}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="2" />
<TextBlock Text="{Binding PatientAddress2}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="3" />
<TextBlock Text="{Binding PatientBsn}" TextWrapping="WrapWholeWords" Grid.Column="3" Grid.Row="0" />
<TextBlock Text="{Binding PatientInsuranceCompany}" TextWrapping="WrapWholeWords" Grid.Column="3" Grid.Row="1"/>
<TextBlock Text="{Binding PatientInsuranceNo}" TextWrapping="WrapWholeWords" Grid.Column="3" Grid.Row="2" />
<TextBlock Text="{Binding PatientEmail}" TextWrapping="WrapWholeWords" Grid.Column="3" Grid.Row="3" />
<TextBlock Text="{Binding PatientPhoneNumber}" TextWrapping="WrapWholeWords" Grid.Column="3" Grid.Row="4" />
<TextBlock TextWrapping="WrapWholeWords" FontWeight="Bold" Grid.Column="4" Grid.Row="0" />
<TextBlock TextWrapping="WrapWholeWords" Grid.Column="4" Grid.Row="1" />
</Grid>
</InlineUIContainer>
</Paragraph>
<Paragraph>
<InlineUIContainer>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="500"/>
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Height="1" Fill="DarkGray"></Rectangle>
</Grid>
</InlineUIContainer>
</Paragraph>
<Paragraph>
<InlineUIContainer>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="55"/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock FontSize="30" FontWeight="Bold" Grid.Column="0" Grid.RowSpan="8" TextAlignment="Left">S</TextBlock>
<TextBlock Grid.Column="1" Grid.Row="0" FontWeight="Bold" Visibility="{Binding Accident, Converter={StaticResource StringToVis}}">Ongeval:</TextBlock>
<TextBlock Text="{Binding Accident}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="0" Visibility="{Binding Accident, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="1" FontWeight="Bold" Visibility="{Binding AmpleEvents, Converter={StaticResource StringToVis}}">Situatie:</TextBlock>
<TextBlock Text="{Binding AmpleEvents}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="1" Visibility="{Binding AmpleEvents, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="2" FontWeight="Bold" Visibility="{Binding AirwayS, Converter={StaticResource StringToVis}}">A:</TextBlock>
<TextBlock Text="{Binding AirwayS}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="2" Visibility="{Binding AirwayS, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="3" FontWeight="Bold" Visibility="{Binding BreathingS, Converter={StaticResource StringToVis}}">B:</TextBlock>
<TextBlock Text="{Binding BreathingS}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="3" Visibility="{Binding BreathingS, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="4" FontWeight="Bold" Visibility="{Binding CirculationS, Converter={StaticResource StringToVis}}">C:</TextBlock>
<TextBlock Text="{Binding CirculationS}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="4" Visibility="{Binding CirculationS, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="5" FontWeight="Bold" Visibility="{Binding DisabilityS, Converter={StaticResource StringToVis}}">D:</TextBlock>
<TextBlock Text="{Binding DisabilityS}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="5" Visibility="{Binding DisabilityS, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="6" FontWeight="Bold" Visibility="{Binding ExposureS, Converter={StaticResource StringToVis}}">E:</TextBlock>
<TextBlock Text="{Binding ExposureS}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="6" Visibility="{Binding ExposureS, Converter={StaticResource StringToVis}}"/>
</Grid>
</InlineUIContainer>
</Paragraph>
<Paragraph>
<InlineUIContainer>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="500"/>
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Height="1" Fill="DarkGray"></Rectangle>
</Grid>
</InlineUIContainer>
</Paragraph>
<Paragraph>
<InlineUIContainer>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="55"/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock FontSize="30" FontWeight="Bold" Grid.Column="0" Grid.RowSpan="6" TextAlignment="Left">B</TextBlock>
<TextBlock Grid.Column="1" Grid.Row="0" FontWeight="Bold" Visibility="{Binding Allergy, Converter={StaticResource StringToVis}}">Allergie:</TextBlock>
<TextBlock Text="{Binding Allergy}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="0" Visibility="{Binding Accident, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="1" FontWeight="Bold" Visibility="{Binding Medication, Converter={StaticResource StringToVis}}">Medicatie:</TextBlock>
<TextBlock Text="{Binding Medication}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="1" Visibility="{Binding Medication, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="2" FontWeight="Bold" Visibility="{Binding PastIllnesses, Converter={StaticResource StringToVis}}">Verleden ziekten:</TextBlock>
<TextBlock Text="{Binding PastIllnesses}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="2" Visibility="{Binding PastIllnesses, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="3" FontWeight="Bold" Visibility="{Binding Insulation, Converter={StaticResource StringToVis}}">Isolatie:</TextBlock>
<TextBlock Text="{Binding Insulation}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="3" Visibility="{Binding Insulation, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="4" FontWeight="Bold" Visibility="{Binding InfectionRisk, Converter={StaticResource StringToVis}}">Besmettingsrisico:</TextBlock>
<TextBlock Text="{Binding InfectionRisk}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="4" Visibility="{Binding InfectionRisk, Converter={StaticResource StringToVis}}"/>
</Grid>
</InlineUIContainer>
</Paragraph>
<Paragraph>
<InlineUIContainer>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="500"/>
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Height="1" Fill="DarkGray"></Rectangle>
</Grid>
</InlineUIContainer>
</Paragraph>
<Paragraph>
<InlineUIContainer>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="55"/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock FontSize="30" FontWeight="Bold" Grid.Column="0" Grid.RowSpan="8" TextAlignment="Left">A</TextBlock>
<TextBlock Grid.Column="1" Grid.Row="0" FontSize="20" Visibility="{Binding HeadAndFace, Converter={StaticResource StringToVis}}">Bevindingen</TextBlock>
<TextBlock Grid.Column="1" Grid.Row="1" FontWeight="Bold" Visibility="{Binding HeadAndFace, Converter={StaticResource StringToVis}}">Hoofd en gelaat:</TextBlock>
<TextBlock Text="{Binding HeadAndFace}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="1" Visibility="{Binding HeadAndFace, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="2" FontWeight="Bold" Visibility="{Binding HeadAndFace, Converter={StaticResource StringToVis}}">Nek/Hals/CWK:</TextBlock>
<TextBlock Text="{Binding Neck}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="2" Visibility="{Binding HeadAndFace, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="3" FontWeight="Bold" Visibility="{Binding HeadAndFace, Converter={StaticResource StringToVis}}">Rug:</TextBlock>
<TextBlock Text="{Binding Back}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="3" Visibility="{Binding HeadAndFace, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="4" FontWeight="Bold" Visibility="{Binding HeadAndFace, Converter={StaticResource StringToVis}}">Thorax:</TextBlock>
<TextBlock Text="{Binding Thorax}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="4" Visibility="{Binding HeadAndFace, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="5" FontWeight="Bold" Visibility="{Binding HeadAndFace, Converter={StaticResource StringToVis}}">Arm:</TextBlock>
<TextBlock Text="{Binding Arms}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="5" Visibility="{Binding HeadAndFace, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="6" FontWeight="Bold" Visibility="{Binding HeadAndFace, Converter={StaticResource StringToVis}}">Abdomen:</TextBlock>
<TextBlock Text="{Binding Abdomen}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="6" Visibility="{Binding HeadAndFace, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="7" FontWeight="Bold" Visibility="{Binding HeadAndFace, Converter={StaticResource StringToVis}}">Bekken:</TextBlock>
<TextBlock Text="{Binding Pelvis}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="7" Visibility="{Binding HeadAndFace, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="8" FontWeight="Bold" Visibility="{Binding HeadAndFace, Converter={StaticResource StringToVis}}">Been:</TextBlock>
<TextBlock Text="{Binding Legs}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="8" Visibility="{Binding HeadAndFace, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="9" FontWeight="Bold" Visibility="{Binding HeadAndFace, Converter={StaticResource StringToVis}}">Uitscheiding:</TextBlock>
<TextBlock Text="{Binding Secreteion}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="9" Visibility="{Binding HeadAndFace, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="10" FontWeight="Bold" Visibility="{Binding HeadAndFace, Converter={StaticResource StringToVis}}">Verloskundig:</TextBlock>
<TextBlock Text="{Binding Gynecology}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="10" Visibility="{Binding HeadAndFace, Converter={StaticResource StringToVis}}"/>
</Grid>
</InlineUIContainer>
</Paragraph>
<Paragraph>
<InlineUIContainer>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="55"/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="1" Grid.Row="0" FontSize="20" Visibility="{Binding TreatmentSectionVisibility}">Behandeling</TextBlock>
<TextBlock Grid.Column="1" Grid.Row="1" FontWeight="Bold" Visibility="{Binding AirwayT, Converter={StaticResource StringToVis}}">A:</TextBlock>
<TextBlock Text="{Binding AirwayT}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="1" Visibility="{Binding AirwayT, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="2" FontWeight="Bold" Visibility="{Binding BreathingT, Converter={StaticResource StringToVis}}">B:</TextBlock>
<TextBlock Text="{Binding BreathingT}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="2" Visibility="{Binding BreathingT, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="3" FontWeight="Bold" Visibility="{Binding CirculationT, Converter={StaticResource StringToVis}}">C:</TextBlock>
<TextBlock Text="{Binding CirculationT}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="3" Visibility="{Binding CirculationT, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="4" FontWeight="Bold" Visibility="{Binding DisabilityT, Converter={StaticResource StringToVis}}">D:</TextBlock>
<TextBlock Text="{Binding DisabilityT}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="4" Visibility="{Binding DisabilityT, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="5" FontWeight="Bold" Visibility="{Binding ExposureT, Converter={StaticResource StringToVis}}">E:</TextBlock>
<TextBlock Text="{Binding ExposureT}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="5" Visibility="{Binding ExposureT, Converter={StaticResource StringToVis}}"/>
</Grid>
</InlineUIContainer>
</Paragraph>
<Paragraph>
<InlineUIContainer>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="500"/>
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Height="1" Fill="DarkGray"></Rectangle>
</Grid>
</InlineUIContainer>
</Paragraph>
<Paragraph>
<InlineUIContainer>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="55"/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock FontSize="30" FontWeight="Bold" Grid.Column="0" Grid.RowSpan="6" TextAlignment="Left">R</TextBlock>
<TextBlock Grid.Column="1" Grid.Row="0" FontSize="20" Visibility="{Binding AdditionalExplanation, Converter={StaticResource StringToVis}}">Verklaring Geen Vervoer</TextBlock>
<TextBlock Grid.Column="1" Grid.Row="1" FontWeight="Bold" Visibility="{Binding AdditionalExplanation, Converter={StaticResource StringToVis}}">Reden:</TextBlock>
<TextBlock Text="{Binding AdditionalExplanation}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="1" Visibility="{Binding AdditionalExplanation, Converter={StaticResource StringToVis}}"/>
<TextBlock Grid.Column="1" Grid.Row="2" FontWeight="Bold" Visibility="{Binding AdditionalExplanationText, Converter={StaticResource StringToVis}}">Toelichting:</TextBlock>
<TextBlock Text="{Binding AdditionalExplanationText}" TextWrapping="WrapWholeWords" Grid.Column="2" Grid.Row="2" Visibility="{Binding AdditionalExplanationText, Converter={StaticResource StringToVis}}"/>
</Grid>
</InlineUIContainer>
</Paragraph>
</RichTextBlock>
</Page>
What should I fix to get normal looking print layout on the thoughbook?
I've managed to fix my solution - I've put all of the TextBlocks inside of the Border with Padding="0" Margin="0" and now everything looks nice on the laptop and toughbook as well:
<Border Padding="0" Margin="0" Grid.Column="0" Grid.Row="1">
<TextBlock Padding="0" Margin="0" Text="{Binding AmbulanceNumber}"
TextWrapping="WrapWholeWords"/>
</Border>

Expanding selected row in gridview on WEH8.1

I am currently developing an application for Windows Embedded Handheld 8.1 and have run into an issue where I have a dynamically expanding grid inside a gridview. My problem is that since this application runs on handheld devices I have a very limited space to use on every row.
What I would like to do is to just show general information on each row and then when a row is tapped or selected in the device, I would like to somehow expand that specific row and show some more detailed information, this seems to be problematic however since as soon as I start messing with a specific rows height, every other row in the ItemTemplate naturally also grows, leaving a lot of blank spaces in the grid.
Normally I would have used a DataGrid and DataGrid.RowDetailsTemplate, but that control does not seem to be implemented in WEH8.1.
So my question is if someone has a solution or possibly a workaround to my problem?
Code Example on GridView Below:
<ScrollViewer Grid.Row="1" Margin="0">
<GridView x:Name="gvCustomerOrderRows">
<GridView.ItemTemplate>
<DataTemplate>
<Grid Background="{Binding BackgroundColor}" Margin="0" Height="{Binding ShowSecondRowHeight}" Tapped="Grid_Tapped" Tag="{Binding kor_row}">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="20"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20"/>
<ColumnDefinition Width="31.25"/>
<ColumnDefinition Width="58.75"/>
<ColumnDefinition Width="105"/>
<ColumnDefinition Width="65"/>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="70"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding kor_pos}" Grid.Row="0" Visibility="{Binding VisibilityHideThenText}" Grid.Column="0" FontSize="14" VerticalAlignment="Center" Margin="0,17,0,16"></TextBlock>
<TextBlock Text="{Binding kor_partno}" Grid.Row="0" Visibility="{Binding VisibilityHideThenText}" Grid.Column="1" FontSize="14" VerticalAlignment="Center" Margin="0,17,0,16" Grid.ColumnSpan="2" ></TextBlock>
<TextBlock Text="{Binding kor_txt}" Grid.Row="0" Grid.Column="3" Grid.ColumnSpan="2" FontSize="14" VerticalAlignment="Center" MaxLines="2" TextWrapping="Wrap"/>
<TextBlock Text="{Binding kor_rqty}" Grid.Row="0" Visibility="{Binding VisibilityHideThenText}" Grid.Column="5" FontSize="14" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" TextAlignment="Center"></TextBlock>
<TextBox x:Name="txtQuantity" Grid.Row="0" Text="{Binding rep_qty, Mode=TwoWay}" Visibility="{Binding VisibilityHideThenText}" Background="{Binding DeliverColor, Mode=TwoWay}" BorderBrush="{Binding DeliverColor, Mode=TwoWay}" InputScope="Number" TextAlignment="Right" Grid.Column="6" GotFocus="txtQuantity_GotFocus" Margin="6,10,-1,0" Height="39"/>
<TextBlock Text="{Binding kor_ldat}" Grid.Row="1" Visibility="{Binding VisibilityHideThenText}" Grid.Column="1" Grid.ColumnSpan="2" FontSize="14" VerticalAlignment="Top" HorizontalAlignment="Left" TextAlignment="Left"></TextBlock>
<TextBlock Text="Stock Loc.: " Grid.Row="1" Grid.Column="3" TextAlignment="Right" VerticalAlignment="Top" FontSize="14" Visibility="{Binding VisibilityHideThenText}"></TextBlock>
<TextBlock Grid.Row="1" Visibility="{Binding VisibilityHideThenText}" Tag="{Binding kor_row}" Grid.Column="4" Grid.ColumnSpan="2" VerticalAlignment="Top" FontWeight="Bold" FontSize="14" Tapped="TextBlock_Tapped" Margin="10,0,0,0"><Underline><Run Text="{Binding SelectedLocation, Mode=TwoWay}"/> </Underline></TextBlock>
<TextBlock Text="{Binding LocQuantity}" Grid.Row="1" Grid.Column="5" VerticalAlignment="Top" Visibility="{Binding VisibilityHideThenText}" FontSize="14" TextAlignment="Center"/>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
</ScrollViewer>

How to prevent textblock to overlapping?

I've tried for this problem the ViewBox but for some resolution the result is strange, the font it's too large and I want maintain my fontsize so the ViewBox isn't good for this goal. This is my structure:
<StackPanel Orientation="Vertical" Grid.Column="0" Grid.Row="5">
<TextBlock TextDecorations="Underline" FontWeight="Bold" HorizontalAlignment="Center">Fattore forma (casa)</TextBlock>
<Label Content="40%" HorizontalAlignment="Center" FontWeight="Bold" FontSize="20"></Label>
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="1" Grid.Row="5" Margin="5,0">
<TextBlock TextDecorations="Underline" FontWeight="Bold" HorizontalAlignment="Center">Fattore forma (fuori)</TextBlock>
<Label Content="35%" HorizontalAlignment="Center" FontWeight="Bold" FontSize="20"></Label>
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="2" Grid.Row="5">
<TextBlock TextDecorations="Underline" FontWeight="Bold" HorizontalAlignment="Center">Totali giocate</TextBlock>
<Label Content="9" HorizontalAlignment="Center" FontWeight="Bold" FontSize="20"></Label>
</StackPanel>
Now the main problem's that if I resize the window to a minimum resolution I get a text overlapping and I want avoid this, what's the best idea for do this? I'm new to wpf so I'm actually learning what's the best solution for this problems.
Image example:
New code as suggested:
<Grid Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="15" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock TextDecorations="Underline" FontWeight="Bold" HorizontalAlignment="Center" Grid.Column="0" Grid.Row="0">Fattore forma (casa)</TextBlock>
<Label Content="40%" HorizontalAlignment="Center" FontWeight="Bold" FontSize="20" Grid.Column="0" Grid.Row="1"></Label>
<TextBlock TextDecorations="Underline" FontWeight="Bold" HorizontalAlignment="Center" Grid.Column="1" Grid.Row="0">Fattore forma (fuori)</TextBlock>
<Label Content="35%" HorizontalAlignment="Center" FontWeight="Bold" FontSize="20" Grid.Column="1" Grid.Row="1"></Label>
<TextBlock TextDecorations="Underline" FontWeight="Bold" HorizontalAlignment="Center" Grid.Column="2" Grid.Row="0">Totali giocate</TextBlock>
<Label Content="9" HorizontalAlignment="Center" FontWeight="Bold" FontSize="20" Grid.Column="2" Grid.Row="1"></Label>
</Grid>
It seems StackPanels are in Grid with Rows and Columns definitions and you didn't paste whole code.
However, you can use TextTrimming="CharacterEllipsis" in TextBlock. It will automatically add dots when text is too long.
or TextWrapping="Wrap" if you want to wrap the text into new line.

ScrollViewer XAML : MouseWheel Not Working

I'm developing an application for a small business and I have a problem with the Horizontal Scroll Viewer.
Horizontal ScrollViewer appears on the screen but the mouse wheel doesn't work.
I Have this XAML Code:
<ScrollViewer ScrollViewer.ZoomMode="Disabled" HorizontalScrollMode="Auto" HorizontalScrollBarVisibility="Auto" ScrollViewer.IsHorizontalScrollChainingEnabled="True" VerticalScrollBarVisibility="Disabled" Margin="0,130,0,0" VerticalContentAlignment="Stretch" ManipulationMode="All">
<Grid Width="1000" HorizontalAlignment="Left" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="250*" ></ColumnDefinition>
<ColumnDefinition Width="250*"/>
<ColumnDefinition Width="250*"/>
<ColumnDefinition Width="250*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="65*" />
<RowDefinition Height="45*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="45*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20,0,0,0" Text="Στοιχεία Πελάτη" FontSize="50"></TextBlock>
<TextBlock Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center" Text="Όνομα :" FontSize="30"></TextBlock>
<TextBlock Grid.Column="0" Grid.Row="2" HorizontalAlignment="Right" VerticalAlignment="Center" Text="Επώνυμο :" FontSize="30"></TextBlock>
<TextBlock Grid.Column="0" Grid.Row="3" HorizontalAlignment="Right" VerticalAlignment="Center" Text="Τηλέφωνο :" FontSize="30"></TextBlock>
<TextBlock Grid.Column="0" Grid.Row="4" HorizontalAlignment="Right" VerticalAlignment="Center" Text="Κινητό :" FontSize="30"></TextBlock>
<TextBlock Grid.Column="0" Grid.Row="5" HorizontalAlignment="Right" VerticalAlignment="Center" Text="Διεύθυνση :" FontSize="30"></TextBlock>
<TextBlock Grid.Column="0" Grid.Row="6" HorizontalAlignment="Right" VerticalAlignment="Center" Text="Πόλη :" FontSize="30"></TextBlock>
<TextBlock Grid.Column="2" Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center" Text="Χώρα :" FontSize="30"></TextBlock>
<TextBlock Grid.Column="2" Grid.Row="2" HorizontalAlignment="Right" VerticalAlignment="Center" Text="Email :" FontSize="30"></TextBlock>
<TextBlock Grid.Column="2" Grid.Row="3" HorizontalAlignment="Right" VerticalAlignment="Center" Text="Α.Φ.Μ :" FontSize="30"></TextBlock>
<TextBlock Grid.Column="2" Grid.Row="4" HorizontalAlignment="Right" VerticalAlignment="Center" Text="ΔΟΥ:" FontSize="30"></TextBlock>
<TextBlock Grid.Column="2" Grid.Row="5" HorizontalAlignment="Right" VerticalAlignment="Center" Text="Περιγραφή:" FontSize="30"></TextBlock>
<TextBox Grid.Column="1" Grid.Row="1" Height="30"></TextBox>
<TextBox Grid.Column="1" Grid.Row="2" Height="30"></TextBox>
<TextBox Grid.Column="1" Grid.Row="3" Height="30"></TextBox>
<TextBox Grid.Column="1" Grid.Row="4" Height="30"></TextBox>
<TextBox Grid.Column="1" Grid.Row="5" Height="30"></TextBox>
<TextBox Grid.Column="1" Grid.Row="6" Height="30"></TextBox>
<TextBox Grid.Column="3" Grid.Row="1" Height="30"></TextBox>
<TextBox Grid.Column="3" Grid.Row="2" Height="30"></TextBox>
<TextBox Grid.Column="3" Grid.Row="3" Height="30"></TextBox>
<TextBox Grid.Column="3" Grid.Row="4" Height="30" VerticalAlignment="Center"></TextBox>
<TextBox Grid.Column="3" Grid.Row="5" Grid.RowSpan="4" AcceptsReturn="True" TextWrapping="Wrap" ScrollViewer.VerticalScrollBarVisibility="Visible"/>
<Button Grid.Column="3" Grid.Row="9" Content="Αποθήκευση" FontSize="22" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"></Button>
</Grid>
</ScrollViewer>
What could be wrong?
In addition to making sure your scrollviewer is being presented at a fixed width, therefore enabling scrolling within the viewer itself (it currently looks like the viewer doesn't need to scroll to display the content), change the viewer declaration to the following.
<ScrollViewer
Style="{StaticResource HorizontalScrollViewerStyle}"
ScrollViewer.IsHorizontalScrollChainingEnabled="True"
Margin="0,130,0,0"
VerticalContentAlignment="Stretch"
ManipulationMode="All">
The style should be defined in StandardStyles.xaml, but if you aren't using that file, the definition is as follows.
<Style x:Key="HorizontalScrollViewerStyle" TargetType="ScrollViewer">
<Setter Property="HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="VerticalScrollBarVisibility" Value="Disabled"/>
<Setter Property="ScrollViewer.HorizontalScrollMode" Value="Enabled" />
<Setter Property="ScrollViewer.VerticalScrollMode" Value="Disabled" />
<Setter Property="ScrollViewer.ZoomMode" Value="Disabled" />
</Style>
Try reducing the grid width and then check. Usually, if grid width is large or 'auto' the content automatically scales to fit and hence scrollviewer doesn't work.

validating model in silverlight MVVM

how to validate in model in silverlight?
The code sample what Im trying to achieve is shown below..
<Grid x:Name="AddnewGrid" Margin="2" DataContext="{Binding SaveUpdateEmp, Mode=TwoWay">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="125"></ColumnDefinition>
<ColumnDefinition Width="10"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock x:Name="EmployeeCode" Text="EmployeeCode" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center"></TextBlock>
<TextBlock x:Name="EmployeeCodeSprtr" Text=":" FontSize="14" Grid.Row="0" Grid.Column="1" VerticalAlignment="Center"></TextBlock>
<TextBox x:Name="txtEmployeeCode" Text="{Binding EmployeeCode, Mode=TwoWay, ValidatesOnDataErrors=True}" Grid.Row="0" Grid.Column="2" VerticalAlignment="Center" Width="150" HorizontalAlignment="Left"></TextBox>
<TextBlock x:Name="EmployeeName" Text="Employee Name" FontSize="14" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center"></TextBlock>
<TextBlock x:Name="EmployeeNameSprtr" Text=":" FontSize="14" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center"></TextBlock>
<TextBox x:Name="txtEmployeeName" Text="{Binding EmployeeName, Mode=TwoWay, ValidatesOnDataErrors=True}" Grid.Row="1" Grid.Column="2" VerticalAlignment="Center" Width="150" HorizontalAlignment="Left"></TextBox>
<TextBlock x:Name="EmployeePW" Text="PassWord" FontSize="14" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center"></TextBlock>
<TextBlock x:Name="EmployeePWSprtr" Text=":" FontSize="14" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center"></TextBlock>
<TextBox x:Name="txtEmployeePW" Text="{Binding EmployeePW, Mode=TwoWay, ValidatesOnDataErrors=True}" Grid.Row="2" Grid.Column="2" VerticalAlignment="Center" Width="150" HorizontalAlignment="Left"></TextBox>
<TextBlock x:Name="EmployeeDesg" Text="Designation" FontSize="14" Grid.Row="3" Grid.Column="0" VerticalAlignment="Center"></TextBlock>
<TextBlock x:Name="EmployeeDesgSprtr" Text=":" FontSize="14" Grid.Row="3" Grid.Column="1" VerticalAlignment="Center"></TextBlock>
<TextBox x:Name="txtEmployeeDesg" Grid.Row="3" Text="{Binding EmployeeDesg, Mode=TwoWay, ValidatesOnDataErrors=True}" Grid.Column="2" VerticalAlignment="Center" Width="150" HorizontalAlignment="Left"></TextBox>
<TextBlock x:Name="DepartmentId" Text="DepartmentID" FontSize="14" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center"></TextBlock>
<TextBlock x:Name="DepartmentIdSprtr" Text=":" FontSize="14" Grid.Row="4" Grid.Column="1" VerticalAlignment="Center"></TextBlock>
<TextBox x:Name="txtDepartmentId" Grid.Row="4" Text="{Binding DepartmentId, Mode=TwoWay, ValidatesOnDataErrors=True}" Grid.Column="2" VerticalAlignment="Center" Width="150" HorizontalAlignment="Left"></TextBox>
<TextBlock x:Name="DepartmentName" Text="Department" FontSize="14" Grid.Row="5" Grid.Column="0" VerticalAlignment="Center"></TextBlock>
<TextBlock x:Name="DepartmentNameSprtr" Text=":" FontSize="14" Grid.Row="5" Grid.Column="1" VerticalAlignment="Center"></TextBlock>
<TextBox x:Name="txtDepartmentName" Grid.Row="5" Text="{Binding DepartmentName, Mode=TwoWay, ValidatesOnDataErrors=True}" Grid.Column="2" VerticalAlignment="Center" Width="150" HorizontalAlignment="Left"></TextBox>
<Button x:Name="CancelButton" Content="Cancel" Click="CancelButton_Click" Grid.Row="6" Grid.Column="2" Width="75" Height="23" HorizontalAlignment="Left" />
<Button x:Name="OKButton" Content="Save" Click="OKButton_Click" Grid.Row="6" Grid.Column="0" Width="75" Height="23" HorizontalAlignment="Left" />
</Grid>
Here the SaveUpdateEmp is object of propertyclass in model. How to validate these fields.??
You need to implement INotifyDataErrorInfo on your model and make sure that you have ValidatesOnDataErrors=True on the controls/properties that you need to validate. I can give you a code sample, but I think this does a better job than I can - http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifydataerrorinfo(v=vs.95).aspx. If you have questions, I'm happy to answer.

Categories

Resources