Event on slider in datatemplate - c#

Having some problems with a slider in my standardstyles.xaml.
How can I add an event on the slider that I can use on the pages where the datatemplate is implemented?
<DataTemplate x:Key="DimmerItemTemplate">
<Grid HorizontalAlignment="Left" Width="225" Height="70" Background="#FFECECEC">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="175"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="38"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="2">
<Image x:Name="imgLow" Stretch="UniformToFill" Source="ms-appx:///Assets/HubPage/TileLowIcon.png" Visibility="{Binding Low}"/>
<Image x:Name="imgHigh" Stretch="UniformToFill" Source="ms-appx:///Assets/HubPage/TileHighIcon.png" Visibility="{Binding High}"/>
</Grid>
<StackPanel Margin="10,0,0,15" VerticalAlignment="Bottom">
<TextBlock Text="{Binding Title}" Foreground="#FF999999" Style="{StaticResource TitleTextStyle}" Margin="0,0,0,5" FontSize="13.333" VerticalAlignment="Top" LineHeight="13.333"/>
<Slider Height="30" Width="160" Name="DimmerSlider" ValueChanged="slider2_ValueChanged">
</Slider>
</StackPanel>
<StackPanel VerticalAlignment="Bottom" Margin="0,0,0,15" Grid.Column="1">
<TextBlock TextWrapping="Wrap" Text="{Binding Level1}" FontFamily="Segoe UI" Foreground="Black" FontSize="13.333" FontWeight="SemiBold" Margin="0"/>
<TextBlock TextWrapping="Wrap" Text="{Binding Level2}" FontFamily="Segoe UI" Foreground="Black" FontSize="13.333" FontWeight="SemiBold" Margin="0"/>
</StackPanel>
</Grid>
</DataTemplate>

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 do i add constraints phone 8.1 UAP Xaml

When I view my app in the Windows Phone 8.1 wvga 4 " the screen works fine as you see in the following screen shot
But when I view it on my 5"lumia it seems messaged up as in screenshot
I know the iPhone uses a constraints system to keep items in place on all resolutions is their something similiar in windows phone 8.1
<Page
x:Class="findaPhysio.findaPhysioSearchDetails"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:findaPhysio"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:drawerLayout="using:DrawerLayout"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid x:Name="RootLayout">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!--Title bar -->
<Grid x:Name="TitleBar" Background="#373A36" Grid.Row ="0" Height="60">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Margin="5" x:Name="DrawerIcon" Grid.Column="0" Source="/Assets/ic_drawer.png" HorizontalAlignment="Left" Tapped="DrawerIcon_Tapped" />
<TextBlock Grid.Column="1" Text="findaPhysio" Foreground="White" VerticalAlignment="Center" FontSize="18"/>
</Grid>
<!--DrawerLayout bar -->
<drawerLayout:DrawerLayout Grid.Row="1" x:Name="DrawerLayout">
<!--MainPage -->
<Grid x:Name="MainFragment" Background="White">
<local:MapView x:Name="MyMap" Background="Black" Zoom="5" ShowTraffic="True" Margin="10,51,0,325" Loaded="MyMap_Loaded"/>
<TextBlock HorizontalAlignment="Left" Margin="18.167,281.833,0,0" FontSize="18" TextWrapping="Wrap" Text="Address" VerticalAlignment="Top" Width="85" Foreground="Black" Height="31" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="False" d:LayoutRounding="Auto">
<TextBlock.RenderTransform>
<CompositeTransform SkewX="4.332" TranslateX="1.174"/>
</TextBlock.RenderTransform>
</TextBlock>
<TextBlock x:Name="txtAddress" HorizontalAlignment="Left" FontSize="18" Margin="116,282,0,0" TextWrapping="Wrap" Text="Address" VerticalAlignment="Top" Width="175" Foreground="Black" RenderTransformOrigin="2.554,0.897"/>
<TextBlock HorizontalAlignment="Left" Margin="22,257,0,0" FontSize="18" TextWrapping="Wrap" Text="Name" VerticalAlignment="Top" RenderTransformOrigin="0,0.256" Foreground="Black" IsTextSelectionEnabled="True"/>
<TextBlock x:Name="txtTelephone" HorizontalAlignment="Left" FontSize="18" Margin="116,331,0,0" TextWrapping="Wrap" Text="Telephone" VerticalAlignment="Top" Foreground="Black" Tapped="txtTelephone_Tapped" Width="143"/>
<TextBlock HorizontalAlignment="Left" Margin="16,331,0,0" FontSize="18" TextWrapping="Wrap" Text="Telephone" VerticalAlignment="Top" Foreground="Black"/>
<TextBlock HorizontalAlignment="Left" Margin="16,325,0,0" FontSize="18" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Foreground="Black"/>
<Button x:Name="btnBookNow" Content="Book Now" HorizontalAlignment="Left" Margin="108,427,0,0" VerticalAlignment="Top" Foreground="#FF589E5B" Background="#FF71C975" Tapped="btnBookNow_Tapped"/>
<TextBlock HorizontalAlignment="Left" Margin="16,304,0,0" FontSize="18" TextWrapping="Wrap" Text="Town" VerticalAlignment="Top" Foreground="Black"/>
<TextBlock x:Name="txtName" HorizontalAlignment="Left" Margin="116,257,0,0" FontSize="18" TextWrapping="Wrap" Text="Name:" VerticalAlignment="Top" RenderTransformOrigin="0,0.256" Foreground="Black" IsTextSelectionEnabled="True"/>
<TextBlock x:Name="txtTown" HorizontalAlignment="Left" Margin="116,304,0,0" FontSize="18" TextWrapping="Wrap" Text="Town" VerticalAlignment="Top" Foreground="Black"/>
<TextBlock HorizontalAlignment="Left" Margin="16,358,0,0" FontSize="18" TextWrapping="Wrap" Text="Web" VerticalAlignment="Top" Foreground="Black"/>
<TextBlock x:Name="txtWeb" HorizontalAlignment="Left" FontSize="12" Margin="116,358,0,0" TextWrapping="Wrap" Text="Web" VerticalAlignment="Top" Foreground="Black" Tapped="txtTelephone_Tapped" Width="263" Height="22"/>
<TextBlock x:Name="lblsp" HorizontalAlignment="Left" Margin="16,385,0,0" FontSize="18" TextWrapping="Wrap" Text="Speciality" VerticalAlignment="Top" Foreground="Black"/>
<TextBlock x:Name="txttxtSpeciality" HorizontalAlignment="Left" FontSize="18" Margin="116,385,0,0" TextWrapping="Wrap" Text="Speciality" VerticalAlignment="Top" Foreground="Black" Tapped="txtTelephone_Tapped" Width="143"/>
</Grid>
<!--Favorites List Section -->
<Grid x:Name="ListFragment">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border Grid.Row="0" Background="#5490CC">
<TextBlock HorizontalAlignment="Center" Margin="0,5,0,5" Text="Physio Details"
FontSize="25"/>
</Border>
<ListView Grid.Row="1" VerticalAlignment="Center" x:Name="ListMenuItems">
<ListView.ItemTemplate>
<DataTemplate>
<Grid Background="White" Margin="0,0,0,1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="{Binding}" Margin="10" VerticalAlignment="Center" FontSize="18" Foreground="Black" />
<Rectangle Grid.Row="1" HorizontalAlignment="Left" Fill="Gray" Width="500" Height="0.5"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</drawerLayout:DrawerLayout>
</Grid>
You should use GridColumns and GridRows property of Grid control for you XAML. You have problem with resolution, because you hardcode margins of you TextBlocks. You should write:
<Grid>
<Grid.RowDefinitions>
<RowDefition />
......
</Grid.RowDefinitions/>
<Grid.ColumnDefinitions>
....
</Grid.ColumnDefiniti‌​ons/>
.....
</Grid>
And after insert your TextBlock to need column and row, for ex.:
<TextBlock Grid.Row="1" Grid.Column="1" />

XAML object overlies the another

My Windows Phone app, have a ListBox, with some binding values.
The TextBlock Binding unidade overlies the TextBlock Binding quantidade when have more of 3 characters.
How do for that the position (margin), changes when the numbers increase.
<controls:PivotItem Header="Consulta" Name="consultaCartao">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ListBox Name="List2" ItemsSource="{Binding produtosCartao}" HorizontalContentAlignment="Stretch" Grid.ColumnSpan="3" Margin="0,182,-66,0" Visibility="Collapsed">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17" Width="432" Height="Auto">
<StackPanel.Background>
<SolidColorBrush Color="#FFE8FF00" Opacity="0.2"/>
</StackPanel.Background>
<TextBlock Grid.Column="0" Text="{Binding descricao}" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Grid.Column="3" Text="{Binding quantidade}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" Margin="20,5,12,0"/>
<TextBlock Grid.Column="3" Text="{Binding valor_preco_a, ConverterCulture=pt-BR, StringFormat=C2}" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}" Margin="300,-30,12,0"/>
<TextBlock Grid.Column="3" Text="{Binding unidade}" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}" Margin="43,-27,12,0"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I would use inline Run elements:
<TextBlock Grid.Column="3" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}" Margin="43,-27,12,0">
<Run Text="{Binding unidade}" />
<Run Text="{Binding quantidade}" />
</TextBlock>
That way the "KG" will always follow on from the number.

Add xaml to top of Listbox

I have a listbox which is filled up with items taken from a data contract. I want to add a bit of xaml to the top of the listbox which takes data from another data contract. How do i go about doing this?
<phone:PivotItem>
<ScrollViewer>
<StackPanel>
<ListBox x:Name="StatusCommentsList"
Background="Transparent"
ItemsSource="{Binding StatusComments}"
u:ScrollViewerMonitor.AtEndCommand="{Binding FetchMoreStatusCommentsDataCommand}" VerticalContentAlignment="Top">
<!-- THIS DOESNT WORK-->
<ListBoxItem>
<Grid Height="auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="67" />
<ColumnDefinition Width="389"/>
</Grid.ColumnDefinitions>
<StackPanel Height="auto" Grid.Column="0" Background="Transparent">
<Border Background="Transparent" BorderThickness="0" Width="62" Height="62" HorizontalAlignment="Left" Margin="0,0,0,5">
<Image Source="{Binding Notification.context.data.created_by.image.thumbnail_link}" Width="62" Height="62"></Image>
</Border>
</StackPanel>
<StackPanel Height="auto" Grid.Column="1" Width="389" MaxWidth="389" Orientation="Vertical" >
<TextBlock TextWrapping="Wrap" Text="{Binding Notification.context.data.created_by.name}" HorizontalAlignment="Stretch" FontSize="30" VerticalAlignment="Center" Margin="0,0,0,5" Foreground="White" Width="389" MaxWidth="389" />
<TextBlock TextWrapping="Wrap" Text="{Binding Notification.context.data.created_on}" HorizontalAlignment="Stretch" FontSize="30" VerticalAlignment="Center" Margin="0,0,0,5" Foreground="White" Width="389" MaxWidth="389" />
<TextBlock TextWrapping="Wrap" Text="{Binding Notification.context.data.rich_value}" HorizontalAlignment="Stretch" FontSize="30" VerticalAlignment="Top" Margin="0,0,0,5" Foreground="White" Width="389" MaxWidth="389" />
</StackPanel>
</Grid>
</ListBoxItem>
<!-- /THIS DOESNT WORK -->
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel VerticalAlignment="Top" Margin="5,0,0,0">
<Button Style="{StaticResource JamesTransparentButton}" Padding="-5,0,-5,-5" Margin="-7,-12,-7,-7" Height="auto" BorderThickness="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Left" UseLayoutRounding="True" FontSize="0.01">
<Grid Height="auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="67" />
<ColumnDefinition Width="389"/>
</Grid.ColumnDefinitions>
<StackPanel Height="auto" Grid.Column="0" Background="Transparent">
<Border Background="Transparent" BorderThickness="0" Width="62" Height="62" HorizontalAlignment="Left" Margin="0,0,0,5">
<Image Source="{Binding created_by.image.thumbnail_link}" Width="62" Height="62"></Image>
</Border>
</StackPanel>
<StackPanel Height="auto" Grid.Column="1" Width="389" MaxWidth="389" Orientation="Vertical" >
<TextBlock Text="{Binding created_by.name}" FontSize="30" VerticalAlignment="Top" Margin="0,0,0,5" Foreground="White" />
<TextBlock Text="{Binding created_on}" FontSize="30" VerticalAlignment="Top" Margin="0,0,0,5" Foreground="White" />
<TextBlock TextWrapping="Wrap" Text="{Binding value}" HorizontalAlignment="Stretch" FontSize="30" VerticalAlignment="Top" Margin="0,0,0,5" Foreground="White" Width="389" MaxWidth="389" />
</StackPanel>
</Grid>
</Button>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</ScrollViewer>
</phone:PivotItem>
I tried just adding a new item to the listbox but the data contract would mean i have to instantiate all the sub levels of objects and it would suckkk as they are different domains.
Keep in mind that i want the entire screen to scroll in union... so that it looks like one big long list, regardless of the first being like a default value.
Put the first item outside the ListBox and disable ScrollViewer for the ListBox so the whole thing will scroll together. Here's an example where the item is a simple TextBlock. You can change it to suit your requirement.
<ScrollViewer>
<StackPanel Orientation="Vertical">
<TextBlock Text="Item 1"/>
<ListBox ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding item}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</ScrollViewer>

Categories

Resources