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>
Related
I have many ListView which contains items, some have content and some do not. I want to show filled box on the position of empty box. How to find out Id of filled box when we drag and how to find Dropbox position and detail of empty box and Listview? Listview Item showing as tile. And also describe types of event.
See Image
<DataTemplate DataType="{x:Type local:FieldSchedule}">
<StackPanel Background="{StaticResource EquipmentItemBackground}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Border Grid.Row="0" Grid.Column="0" BorderBrush="Black" BorderThickness="1,1,1,0" CornerRadius="5,5,0,0" Width="243" Height="35"
VerticalAlignment="Center" HorizontalAlignment="Center" Padding="1" Background="#CFE2FC">
<StackPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<!--<ColumnDefinition Width="*"></ColumnDefinition>-->
</Grid.ColumnDefinitions>
<!--<TextBlock Grid.Row="0" Grid.Column="0" Text="Ticket #" Foreground="Black" FontSize="10"
VerticalAlignment="Center" HorizontalAlignment="Right"/>-->
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding OrderID}" Foreground="Black" FontSize="25"
VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0,0,0"/>
</Grid>
</StackPanel>
</Border>
<Border Grid.Row="1" Grid.Column="0" x:Name="Border" BorderBrush="Black" CornerRadius="0,0,5,5" BorderThickness="1,0,1,1" Width="243"
VerticalAlignment="Center" HorizontalAlignment="Center" Padding="1" Height="110" Background="White" AllowDrop="True" DragEnter="Border_DragEnter_1" DragLeave="Border_DragLeave_1" Drop="Border_Drop">
<StackPanel>
<Grid Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding ContactName}" Foreground="Black" FontSize="13" TextAlignment="Left"
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="5,1,0,0" TextWrapping="NoWrap" FontWeight="Medium"/>
<TextBlock Grid.Row="1" Grid.Column="0" Text="{Binding JobName}" Foreground="Black" FontSize="13" TextAlignment="Left"
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="5,1,0,0" TextWrapping="Wrap" FontWeight="Medium"/>
<TextBlock Grid.Row="2" Grid.Column="0" Text="{Binding City}" Foreground="Black" FontSize="13" TextAlignment="Left"
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="5,1,0,0" TextWrapping="Wrap" FontWeight="Medium"/>
<TextBlock Grid.Row="3" Grid.Column="0" Text="{Binding EarlyIn}" Foreground="Black" FontSize="13" TextAlignment="Left"
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="5,1,0,0" FontWeight="Medium"/>
<TextBlock Grid.Row="3" Grid.Column="0" Text="{Binding StreetAddress}" Foreground="Black" FontSize="13" TextAlignment="Left"
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="57,1,0,0" TextWrapping="Wrap" FontWeight="Medium"/>
<Button Grid.Row="3" Grid.Column="0" x:Name="toggleButton1" Margin="0,0,10,0" VerticalAlignment="Center" HorizontalAlignment="Right" Width="24" Height="30" Padding="0" Background="White" BorderBrush="White" BorderThickness="0">
<Image Name="imgCalendar12" HorizontalAlignment="Right" Width="20" Height="30" Source="/Assets/cal.JPG" Margin="0"/>
<ie:Interaction.Triggers>
<ie:EventTrigger EventName="Click">
<ie:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=telerik:RadTileList},Path=DataContext.UnassingedCalendarPopUpComand}" CommandParameter="{Binding ElementName=toggleButton1}">
</ie:InvokeCommandAction>
</ie:EventTrigger>
</ie:Interaction.Triggers>
</Button>
</Grid>
</StackPanel>
</Border>
</Grid>
</StackPanel>
<!--<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadTileList}}}" Value="True" >
<Setter TargetName="Border" Property="Background" Value="{StaticResource EquipmentItemSelectedBackground}" />
</DataTrigger>
</DataTemplate.Triggers>-->
</DataTemplate>
I have an itemtemplate with just two texts blocks in it but when a text block is growing because of a word wrap, the itemtemplate grid is not growing.
How can I do that ? Thanks for your help !
<DataTemplate x:Key="ArtistTemplate">
<Grid Height="60" Width="436">
<Grid.RowDefinitions>
<RowDefinition Height="auto" MinHeight="34" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<TextBlock TextWrapping="Wrap" Text="{Binding Name}" Margin="10,0" Foreground="White" FontSize="26" FontWeight="Bold" Height="34" VerticalAlignment="Top"/>
<TextBlock TextWrapping="Wrap" Text="{Binding NbAlbum, Converter={StaticResource Converters_IntToStringWithNbAlbum}}" Margin="10,0,10,-21" Foreground="White" FontSize="12" Height="16" VerticalAlignment="Bottom" Grid.Row="1"/>
</Grid>
</DataTemplate>
Set the height of grid to "Auto".
<Grid Height="Auto" Width="436">
<Grid.RowDefinitions>
<RowDefinition Height="auto" MinHeight="34" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<TextBlock TextWrapping="Wrap" Text="{Binding Name}" Margin="10,0" Foreground="White" FontSize="26" FontWeight="Bold" Height="34" VerticalAlignment="Top"/>
<TextBlock TextWrapping="Wrap" Text="{Binding NbAlbum, Converter={StaticResource Converters_IntToStringWithNbAlbum}}" Margin="10,0,10,-21" Foreground="White" FontSize="12" Height="16" VerticalAlignment="Bottom" Grid.Row="1"/>
</Grid>
I have three radio buttons and three group boxes and based on the selection of the radio button, group box should have been visible or collapsed, but nothing seems to work here. The code for my constructor gets executed, but still it seems things are overlapping each other.
<baseControls:MaintainTemplate Style="{StaticResource {x:Type baseControls:MaintainTemplate}}" TitleText="{Binding TitleText}">
<baseControls:MaintainTemplate.TabSection>
<Grid>
<GroupBox>
<GroupBox.Header>
<TextBlock Text="Case Information" Style="{StaticResource TextBlockWhite}"/>
</GroupBox.Header>
<GroupBox.Content>
<Grid x:Name="GridMain">
<Grid.RowDefinitions>
<RowDefinition Style="{StaticResource AutoHeightRowDefinition}"/>
<RowDefinition Style="{StaticResource MinHeightRowDefinition}"/>
<RowDefinition Style="{StaticResource AutoHeightRowDefinition}"/>
<RowDefinition Style="{StaticResource MinHeightRowDefinition}"/>
<RowDefinition Style="{StaticResource AutoHeightRowDefinition}"/>
<RowDefinition Style="{StaticResource MinHeightRowDefinition}"/>
<RowDefinition Style="{StaticResource MaxHeightRowDefinition}"/>
<RowDefinition Style="{StaticResource MinHeightRowDefinition}"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/>
<ColumnDefinition Style="{StaticResource MaxWidthColumnDefinition}"/>
<ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="1" x:Name="GridSelectCustomer">
<Grid.RowDefinitions>
<RowDefinition Style="{StaticResource MinHeightRowDefinition}"/>
<RowDefinition Style="{StaticResource AutoHeightRowDefinition}"/>
<RowDefinition Style="{StaticResource MinHeightRowDefinition}"/>
<RowDefinition Style="{StaticResource AutoHeightRowDefinition}"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/>
<ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/>
<ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/>
<ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/>
<ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/>
<ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/>
<ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="1" Text="Select Customer" Style="{StaticResource TextBlockWhite}"/>
<ComboBox Grid.Row="1" Grid.Column="2" Width="150" ItemsSource="{Binding Customers}"
DisplayMemberPath="FirstName" SelectedValue="{Binding SelectedCustomer}"/>
<Button Grid.Row="1" Grid.Column="4" Content="Quick Search"/>
<Button Grid.Row="1" Grid.Column="6" Content="Add New Customer"/>
<TextBlock Grid.Row="3" Text="Reference No" Style="{StaticResource TextBlockWhite}"/>
<TextBox Grid.Row="3" Grid.Column="2"/>
<TextBlock Grid.Row="3" Text="Case No" Grid.Column="4" Style="{StaticResource TextBlockWhite}"/>
<TextBox Grid.Row="3" Grid.Column="6" Style="{StaticResource TextBoxReadOnly}"/>
</Grid>
<GroupBox Grid.Row="2" Grid.Column="1" x:Name="GroupBoxCustomerInfo">
<GroupBox.Header>
<TextBlock Text="Customer Details" Style="{StaticResource TextBlockWhite}"></TextBlock>
</GroupBox.Header>
<GroupBox.Content>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/>
<ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/>
<ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/>
<ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/>
<ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/>
<ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/>
<ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/>
<ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Style="{StaticResource AutoHeightRowDefinition}"/>
<RowDefinition Style="{StaticResource MinHeightRowDefinition}"/>
<RowDefinition Style="{StaticResource AutoHeightRowDefinition}"/>
<RowDefinition Style="{StaticResource MinHeightRowDefinition}"/>
<RowDefinition Style="{StaticResource AutoHeightRowDefinition}"/>
</Grid.RowDefinitions>
<TextBlock Style="{StaticResource TextBlockWhite}" Grid.Row="0" Grid.Column="1" Text="Name"/>
<TextBox Style="{StaticResource TextBoxReadOnly}" Grid.Column="3"></TextBox>
<TextBlock Style="{StaticResource TextBlockWhite}" Grid.Row="0" Grid.Column="5" Text="Phone No"/>
<TextBox Style="{StaticResource TextBoxReadOnly}" Grid.Column="7"></TextBox>
<TextBlock Style="{StaticResource TextBlockWhite}" Grid.Row="2" Grid.Column="1" Text="Father's Name"/>
<TextBox Style="{StaticResource TextBoxReadOnly}" Grid.Column="3" Grid.Row="2"></TextBox>
<TextBlock Style="{StaticResource TextBlockWhite}" Grid.Row="4" Grid.Column="1" Text="Address"/>
<TextBox Style="{StaticResource TextBoxMultiLineReadOnly}" Grid.Row="4" Grid.Column="3" ></TextBox>
<TextBlock Style="{StaticResource TextBlockWhite}" Grid.Row="2" Grid.Column="5" Text="Date Of Birth"/>
<TextBox Style="{StaticResource TextBoxReadOnly}" Grid.Column="7" Grid.Row="2"></TextBox>
</Grid>
</GroupBox.Content>
</GroupBox>
<GroupBox Grid.Row="4" Grid.Column="1" x:Name="GroupBoxCaseType">
<GroupBox.Header>
<TextBlock Text="Case Type" Style="{StaticResource TextBlockWhite}"/>
</GroupBox.Header>
<GroupBox.Content>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/>
<ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/>
<ColumnDefinition Style="{StaticResource MaxWidthColumnDefinition}"/>
<ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/>
<ColumnDefinition Style="{StaticResource MaxWidthColumnDefinition}"/>
<ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/>
<ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/>
</Grid.ColumnDefinitions>
<RadioButton Grid.Column="1" x:Name="rdbMonthlyInterest" Content="Monthly Interest"
Style="{StaticResource RadioButtonWhite}" IsChecked="{Binding IsMonthlyInterestChecked}"/>
<RadioButton Grid.Column="3" x:Name="rdbDailyInstallment" Content="Daily Installment"
Style="{StaticResource RadioButtonWhite}" IsChecked="{Binding IsDailyInstallmentChecked}"/>
<RadioButton Grid.Column="5" x:Name="rdbMonthlyInstallment" Content="Monthly Installment"
Style="{StaticResource RadioButtonWhite}" IsChecked="{Binding IsMonthlyInstallmentChecked}"/>
</Grid>
</GroupBox.Content>
</GroupBox>
<GroupBox Grid.Row="6" Grid.Column="1" Visibility="{Binding Path=IsMonthlyInterestChecked, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource VisibilityConverter}}" >
<GroupBox.Header>
<TextBlock Style="{StaticResource TextBlockWhite}">Monthly Interest</TextBlock>
</GroupBox.Header>
</GroupBox>
<GroupBox Grid.Row="6" Grid.Column="1" Visibility="{Binding Path=IsDailyInstallmentChecked, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource VisibilityConverter}}" >
<GroupBox.Header>
<TextBlock Style="{StaticResource TextBlockWhite}">Daily Installment</TextBlock>
</GroupBox.Header>
</GroupBox>
<GroupBox Grid.Row="6" Grid.Column="1" Visibility="{Binding Path=InMonthlyInstallmentChecked, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource VisibilityConverter}}" >
<GroupBox.Header>
<TextBlock Style="{StaticResource TextBlockWhite}">Monthly Installment</TextBlock>
</GroupBox.Header>
</GroupBox>
</Grid>
</GroupBox.Content>
</GroupBox>
</Grid>
</baseControls:MaintainTemplate.TabSection>
</baseControls:MaintainTemplate>
Here is the code for the converter
namespace Finance.MainUI.Common.Converters
{
public class BoolToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool) value ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter,CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
Change the Visibility binding to:
<GroupBox Grid.Row="7" Grid.Column="1"
Visibility="{Binding
RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type UserControl}}
Path=DataContext.IsMonthlyInterestChecked,
UpdateSourceTrigger=PropertyChanged,
Converter={StaticResource VisibilityConverter}}" >
Then add a property IsMonthlyInterestChecked to your ViewModel and bind RadioButton to it:
<RadioButton Grid.Column="0" x:Name="rdbMonthlyInterest"
Content="Monthly Interest"
Style="{StaticResource RadioButtonWhite}"
IsChecked="{Binding IsMonthlyInterestChecked}"/>
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.
I have a usercontrol which I want to use as a DataTemplate in a Listbox.
This works:
<ListBox>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid x:Name="Grid" Height="100" Width="880" Background="LightGray">
<Grid.RowDefinitions>
<RowDefinition Height="24"/>
<RowDefinition Height="24"/>
<RowDefinition Height="24"/>
<RowDefinition Height="24"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="190" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="190" />
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Grid.Row="0">Client</Label>
<Label Grid.Column="0" Grid.Row="2">Contact</Label>
<Label Grid.Column="1" Grid.Row="0">Date Presentation</Label>
<Label Grid.Column="2" Grid.Row="0">Action</Label>
<Label Grid.Column="3" Grid.Row="0">Date Interview</Label>
<Label Grid.Column="3" Grid.Row="2">Time Interview</Label>
<Label Grid.Column="4" Grid.Row="0">Remarks</Label>
<Label Grid.Column="5" Margin="0,0,2,0">managed by</Label>
<ComboBox Grid.Column="0" Grid.Row="1" Margin="2" Text="{Binding Path=Customer}">
<!--Template-->
</ComboBox>
<TextBox Grid.Column="0" Grid.Row="3" Margin="2" Text="{Binding Path=Contact}"></TextBox>
<TextBox Grid.Column="1" Grid.Row="1" Margin="2" Text="{Binding Path=PresentationDate}"></TextBox>
<ComboBox Grid.Column="2" Grid.Row="1" Margin="2" Text="{Binding Path=Action}">
<!--Template-->
</ComboBox>
<TextBox Grid.Column="3" Grid.Row="1" Margin="2" Text="{Binding Path=InterviewDate}"></TextBox>
<TextBox Grid.Column="3" Grid.Row="3" Margin="2" Text="{Binding Path=InterviewTime}"></TextBox>
<TextBox Grid.Column="4" Grid.Row="1" Grid.RowSpan="3" Margin="2" Text="{Binding Path=Remarks}"></TextBox>
<StackPanel Orientation="Horizontal" Grid.Column="5" Grid.Row="1" >
<ComboBox Width="124" Text="{Binding Path=Manager}" Margin="2"></ComboBox>
<Button Width="60" Height="20" Margin="4,0,0,0" >Mail</Button>
</StackPanel>
<CheckBox Grid.Column="5" Grid.Row="3" Margin="2,2,4,2">Rejection communicated</CheckBox>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
If I put the exact same code from between the <DataTemplate> tags:
<UserControl x:Class="CandiMan.View.CandidatePresentationControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cm="clr-namespace:CandiMan;assembly=CandiMan"
xmlns:vw="clr-namespace:CandiMan.View;assembly=CandiMan"
xmlns:vm="clr-namespace:CandiMan.ViewModel;assembly=CandiMan"
Height="100" Width="880" BorderBrush="Black" BorderThickness="1">
<Grid x:Name="Grid" Height="100" Width="880" Background="LightGray">
<Grid.RowDefinitions>
<RowDefinition Height="24"/>
<RowDefinition Height="24"/>
<RowDefinition Height="24"/>
<RowDefinition Height="24"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="190" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="190" />
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Grid.Row="0">Client</Label>
<Label Grid.Column="0" Grid.Row="2">Contact</Label>
<Label Grid.Column="1" Grid.Row="0">Date Presentation</Label>
<Label Grid.Column="2" Grid.Row="0">Action</Label>
<Label Grid.Column="3" Grid.Row="0">Date Interview</Label>
<Label Grid.Column="3" Grid.Row="2">Time Interview</Label>
<Label Grid.Column="4" Grid.Row="0">Remarks</Label>
<Label Grid.Column="5" Margin="0,0,2,0">managed by</Label>
<ComboBox Grid.Column="0" Grid.Row="1" Margin="2" Text="{Binding Path=Customer}">
<!--Template-->
</ComboBox>
<TextBox Grid.Column="0" Grid.Row="3" Margin="2" Text="{Binding Path=Contact}"></TextBox>
<TextBox Grid.Column="1" Grid.Row="1" Margin="2" Text="{Binding Path=PresentationDate}"></TextBox>
<ComboBox Grid.Column="2" Grid.Row="1" Margin="2" Text="{Binding Path=Action}">
<!--Template-->
</ComboBox>
<TextBox Grid.Column="3" Grid.Row="1" Margin="2" Text="{Binding Path=InterviewDate}"></TextBox>
<TextBox Grid.Column="3" Grid.Row="3" Margin="2" Text="{Binding Path=InterviewTime}"></TextBox>
<TextBox Grid.Column="4" Grid.Row="1" Grid.RowSpan="3" Margin="2" Text="{Binding Path=Remarks}"></TextBox>
<StackPanel Orientation="Horizontal" Grid.Column="5" Grid.Row="1" >
<ComboBox Width="124" Text="{Binding Path=Manager}" Margin="2"></ComboBox>
<Button Width="60" Height="20" Margin="4,0,0,0" >Mail</Button>
</StackPanel>
<CheckBox Grid.Column="5" Grid.Row="3" Margin="2,2,4,2">Rejection communicated</CheckBox>
</Grid>
</UserControl>
into a usercontrol named CandidatePresentationControl and do it like
<ListBox>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<vw:CandidatePresentationControl/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
it does not get rendered. No errors, just an empty listbox. Can someone help me??
Thank you!
edit: I forgot something, dunno if it matters: The whole thing I'm doing this in, is a usercontrol, too.
It shouldn't matter, that your referenced UserControl is within another UserControl. Try these steps to better debug your XAML-code: http://beacosta.com/blog/?p=52
Since you have your data hard wired in XAML, the only way to explain the empty ListBox is, that your UserControl can't be found by the parent UserControl, imo.
<ListBox>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<vw:CandidatePresentationControl DataContext="{Binding}"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
You have to write this way in order to bind datacontext, I would suggest you look at MVVM that will give you idea on how to do it even better way.