listbox scroller not working properly when i try to scroller Down .This is my code and i am open this page on popup . How to solve this prob . Please Help .thankyou ....................................................................................................................................................................................
<phone:PhoneApplicationPage
x:Class="PdfReader.Views.BookMark"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True" >
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent" Height="auto">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<!--<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>-->
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="0,0,0,0">
<StackPanel Background="#6c4a7d" Width="auto" Margin="0,248,0,95">
<StackPanel Orientation="Horizontal">
<Button x:Name="btnCancel" Content="Cancel" Click="btnCancel_Click"/>
<TextBlock Text="BookmarkList" VerticalAlignment="Center" Margin="100 0 0 0"></TextBlock>
<Button Margin="70,0,0,0" Background="Transparent" HorizontalAlignment="Left" BorderBrush="Transparent" Width="80" Height="70" Name="DeleteAll" Click="DeleteAll_Click" Canvas.ZIndex="10" >
<StackPanel Width="68" Height="60" Margin="0,-5,-40,-14" UseLayoutRounding="False" RenderTransformOrigin="0.45,0.5" >
<StackPanel.Projection>
<PlaneProjection RotationX="24" RotationY="9"/>
</StackPanel.Projection>
<StackPanel.RenderTransform>
<CompositeTransform TranslateX="-1" TranslateY="-12"/>
</StackPanel.RenderTransform>
<TextBlock Visibility="Collapsed" Text="{Binding Bookname}"></TextBlock>
<TextBlock Visibility="Collapsed" Text="{Binding Pageno}"></TextBlock>
<Image Source="/Assets/delete_bookmark.png" Width="74" Height="65"
HorizontalAlignment="Center" VerticalAlignment="Center" Margin="8,-4,11,570" Canvas.ZIndex="62" RenderTransformOrigin="0.55,0.5">
<Image.Projection>
<PlaneProjection CenterOfRotationX="0.1" LocalOffsetX="-1"/>
</Image.Projection>
<Image.RenderTransform>
<CompositeTransform TranslateX="1" ScaleX="0.95"/>
</Image.RenderTransform>
</Image>
</StackPanel>
</Button>
<!--<Button x:Name="btnOK" Content="OK"/>-->
</StackPanel>
<ListBox Name="Bookmark_List" SelectionChanged="Bookmark_List_SelectionChanged" >
<ListBox.ItemTemplate >
<DataTemplate>
<Grid Margin="10 10 10 10">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Bookname}" Foreground="White" VerticalAlignment="Center"></TextBlock>
<TextBlock Text="{Binding Pageno}" FontSize="29" VerticalAlignment="Center" Margin="30 0 0 0" Foreground="White"></TextBlock>
<!--<Button Margin="5 0 0 0" Background="Transparent" HorizontalAlignment="Right" BorderBrush="Transparent" Width="80" Height="70" Name="DeleteBookmark" Click="DeleteBookmark_Click" >
<StackPanel>
<TextBlock Visibility="Collapsed" Text="{Binding Bookname}"></TextBlock>
<TextBlock Visibility="Collapsed" Text="{Binding Pageno}"></TextBlock>
<Image Source="/Assets/delete_bookmark.png" Width="62" Height="100"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
</Button>-->
<Button Margin="5 0 0 0" Background="Transparent" HorizontalAlignment="Right" BorderBrush="Transparent" Width="80" Height="70" Click="DeleteBookmark_Click" Name="DeleteBookmark" >
<StackPanel >
<TextBlock Visibility="Collapsed" Text="{Binding Bookname}"></TextBlock>
<TextBlock Visibility="Collapsed" Text="{Binding Pageno}"></TextBlock>
<Image Source="/Assets/delete_book.png" Width="45" Height="30"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
</Button>
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</Grid>
</Grid>
</phone:PhoneApplicationPage>
Please apply a height to listbox and set ScrollViewer.VerticalScrollBarVisibility
<ListBox Name="Bookmark_List" Height="450" ScrollViewer.VerticalScrollBarVisibility="Visible" SelectionChanged="Bookmark_List_SelectionChanged" >
Related
I have a listBox with a checkbox I want to manage the alignment through setting the vertical alignment.
I have seen several solution here e.g. set verticalContentAlignment or verticalAlignment to top but that didn't work.
I've also seen some setting a style but couldn't manage to make it done.
What I'd like is to know WHY the ONLY element is down there. I can't understand why it's stuck in the middle.
Here's my code:
<ListBox x:Name="lb2Tab3" HorizontalContentAlignment="Stretch" FontSize="{StaticResource BUTTON_FONTSIZE}" Background="{x:Null}" BorderBrush="{x:Null}" Margin="0,0,0.8,0" >
<CheckBox x:Name="cbEasyRunManagesPcDmis" Margin="20" Content="EasyRun Manages PC-DMIS" HorizontalAlignment="Left" VerticalAlignment="Top" Click="cbTouchScreen_Click" />
</ListBox>
thanx for any help
Patrick
--- EDIT ---
As requested by Frisbee here is the complete xaml. Sorry for its length:
<Base:WindowViewBase x:Class="EasyRun.Views.MainView.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:Base="clr-namespace:Cannoli.Base;assembly=Cannoli"
xmlns:design="clr-namespace:EasyRun.Views.MainView.Design"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:System="clr-namespace:System;assembly=mscorlib"
xmlns:CannoliBorderlessWindow="clr-namespace:CannoliBorderlessWindow;assembly=Cannoli.BorderlessWindow"
d:DesignWidth="212.32" d:DesignHeight="109.92"
Title="EASY RUN 2.0" Height="600" Width="900" MinWidth="500" FontFamily="/EasyRun2.0;component/Resources/Fonts/#FontAwesome" Icon="/EasyRun2.0;component/Resources/Images/Lightning.png"
>
<d:WindowViewBase.DataContext>
<design:DesignMainViewModel />
</d:WindowViewBase.DataContext>
<i:Interaction.Behaviors>
<CannoliBorderlessWindow:CannoliBorderlessWindowBehavior/>
</i:Interaction.Behaviors>
<!-- RISORSE GLOBALI: VARIABILI -->
<Window.Resources>
<System:Double x:Key="BUTTON_HEIGHT">50</System:Double>
<System:Double x:Key="BUTTON_FONTSIZE">20</System:Double>
</Window.Resources>
<Grid x:Name="MainGrid">
<Grid.Background>
<ImageBrush ImageSource="/EasyRun2.0;component/Resources/Images/gradientWallpaper.jpg"/>
</Grid.Background>
<TextBlock Text="{Binding WelcomeMessage}" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Margin="428,128,99.6,228"/>
<StackPanel Orientation="Vertical" VerticalAlignment="Bottom" Margin="0,0,0,20">
</StackPanel>
<TabControl TabStripPlacement="Left" Margin="0,0,-0.4,0" Background="{x:Null}">
<!-- +++++++++++++ TAB1 ++++++++++++ -->
<TabItem Name="tabItem1" HorizontalAlignment="Center" Height="80" FontSize="50" Background="{x:Null}" VerticalAlignment="Top" >
<TabItem.Header>
<StackPanel>
<TextBlock HorizontalAlignment="Center" Text=""/>
<TextBlock Name="tbTab1" HorizontalAlignment="Center" Visibility="Hidden" FontSize="20"/>
</StackPanel>
</TabItem.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border x:Name="Border1Tab1" BorderBrush="Gainsboro" BorderThickness="5" Width="200" CornerRadius="8,8,3,3" Margin="10,10,10,10.4" >
<ListBox x:Name="lbButtons1" Background="{x:Null}" BorderBrush="{x:Null}" Margin="10,10,10,10" />
</Border>
<Border x:Name="Border2Tab1" BorderBrush="Gainsboro" MinWidth="100" BorderThickness="5" CornerRadius="8,8,3,3" Grid.Column="1" Margin="10,10,9.2,10" />
</Grid>
</TabItem>
<!-- +++++++++++++ TAB2 ++++++++++++ -->
<TabItem Name="tabItem2" HorizontalAlignment="Center" Height="80" FontSize="50">
<TabItem.Header>
<StackPanel>
<TextBlock Text=""/>
<TextBlock Name="tbTab2" Visibility="Hidden" FontSize="20"/>
</StackPanel>
</TabItem.Header>
<TabItem.Background>
<ImageBrush/>
</TabItem.Background>
</TabItem>
<!-- +++++++++++++ TAB3 ++++++++++++ -->
<TabItem Name="tabItem3" HorizontalAlignment="Center" Height="80" FontSize="50" Background="{x:Null}" >
<TabItem.Header>
<StackPanel>
<TextBlock Text="" HorizontalAlignment="Center" />
<TextBlock Name="tbTab3" Visibility="Hidden" FontSize="20"/>
</StackPanel>
</TabItem.Header>
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border x:Name="Border1Tab3" BorderBrush="Gainsboro" BorderThickness="5" Width="200" CornerRadius="8,8,3,3" Margin="10,10,10,10" >
<ListBox x:Name="lbButtons3" FontSize="{StaticResource BUTTON_FONTSIZE}" HorizontalContentAlignment="Stretch" Background="{x:Null}" BorderBrush="{x:Null}" >
<Button Name="bt1Tab3" Background="{x:Null}" Content="1" Click="Button_Click" />
<Button Name="bt2Tab3" Background="{x:Null}" Height="{StaticResource BUTTON_HEIGHT}" Content="2" Click="Button_Click"/>
<Button Name="bt3Tab3" Background="{x:Null}" Height="{StaticResource BUTTON_HEIGHT}" Content="3" Click="Button_Click"/>
<Button Name="bt4Tab3" Background="{x:Null}" Height="{StaticResource BUTTON_HEIGHT}" Content="4" Click="Button_Click"/>
<Button Name="bt5Tab3" Background="{x:Null}" Height="{StaticResource BUTTON_HEIGHT}" Content="5" Click="Button_Click"/>
<Button Name="bt6Tab3" Background="{x:Null}" Height="{StaticResource BUTTON_HEIGHT}" Content="6" Click="Button_Click"/>
<Button Name="bt7Tab3" Background="{x:Null}" Height="{StaticResource BUTTON_HEIGHT}" Content="7" Click="Button_Click"/>
<Button Name="bt8Tab3" Background="{x:Null}" Height="{StaticResource BUTTON_HEIGHT}" Content="8" Click="Button_Click"/>
</ListBox>
</Border>
<Border x:Name="Border2Tab3" BorderBrush="Gainsboro" MinWidth="100" BorderThickness="5" CornerRadius="8,8,3,3" Grid.Column="1" Margin="10,10,10,10" >
<StackPanel >
<ListBox x:Name="lb1Tab3" HorizontalContentAlignment="Stretch" FontSize="{StaticResource BUTTON_FONTSIZE}" Background="{x:Null}" BorderBrush="{x:Null}" Margin="0,0,0.4,0" d:IsHidden="True" >
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="lbLanguage" Margin="20" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Center" TextAlignment="Center" Grid.Row="1"><Run Text="Language"/></TextBlock>
<ComboBox x:Name="cmbLanguages" Margin="20" HorizontalAlignment="Left" VerticalAlignment="Center" Width="246" Height="35" DropDownClosed="cmbLanguages_DropDownClosed"/>
</StackPanel>
<CheckBox x:Name="cbTouchScreen" Margin="20" Content="Use touch screen" HorizontalAlignment="Left" VerticalAlignment="Top" Click="cbTouchScreen_Click" />
<CheckBox x:Name="cbEnableImages" Margin="20" Content="Enable Images" HorizontalAlignment="Left" VerticalAlignment="Top" />
<StackPanel Name="spImageDimension" Orientation="Horizontal">
<TextBlock x:Name="lbImageDimension" Margin="20" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Center" TextAlignment="Center"><Run Text="Image dimension"/></TextBlock>
<ComboBox x:Name="cmbImageDimension" Margin="20" Text="250 px" HorizontalAlignment="Left" DropDownClosed="cmbImageDimension_DropDownClosed" VerticalAlignment="Center" Width="246" Height="35" IsEditable="True">
<TextBlock ><Run Text="50 px"/></TextBlock>
<TextBlock ><Run Text="100 px"/></TextBlock>
<TextBlock ><Run Text="150 px"/></TextBlock>
<TextBlock ><Run Text="200 px"/></TextBlock>
<TextBlock ><Run Text="250 px"/></TextBlock>
</ComboBox>
</StackPanel>
</ListBox>
<ListBox x:Name="lb2Tab3" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Top" FontSize="{StaticResource BUTTON_FONTSIZE}" Background="{x:Null}" BorderBrush="{x:Null}" Margin="0,0,0.8,0" >
<CheckBox x:Name="cbEasyRunManagesPcDmis" Margin="20" Content="EasyRun Manages PC-DMIS" HorizontalAlignment="Left" VerticalAlignment="Top" Click="cbTouchScreen_Click" />
</ListBox>
<ListBox x:Name="lb3Tab3" HorizontalContentAlignment="Stretch" FontSize="{StaticResource BUTTON_FONTSIZE}" Background="{x:Null}" BorderBrush="{x:Null}" Margin="0,0,0.4,0" />
<ListBox x:Name="lb4Tab3" HorizontalContentAlignment="Stretch" FontSize="{StaticResource BUTTON_FONTSIZE}" Background="{x:Null}" BorderBrush="{x:Null}" Margin="0,0,0.4,0" d:IsHidden="True" >
</ListBox>
<ListBox x:Name="lb5Tab3" HorizontalContentAlignment="Stretch" FontSize="{StaticResource BUTTON_FONTSIZE}" Background="{x:Null}" BorderBrush="{x:Null}" Margin="0,0,0.4,0" d:IsHidden="True" >
</ListBox>
<ListBox x:Name="lb6Tab3" HorizontalContentAlignment="Stretch" FontSize="{StaticResource BUTTON_FONTSIZE}" Background="{x:Null}" BorderBrush="{x:Null}" Margin="0,0,0.4,0" d:IsHidden="True" >
</ListBox>
<ListBox x:Name="lb7Tab3" HorizontalContentAlignment="Stretch" FontSize="{StaticResource BUTTON_FONTSIZE}" Background="{x:Null}" BorderBrush="{x:Null}" Margin="0,0,0.4,0" d:IsHidden="True" >
</ListBox>
<ListBox x:Name="lb8Tab3" HorizontalContentAlignment="Stretch" FontSize="{StaticResource BUTTON_FONTSIZE}" Background="{x:Null}" BorderBrush="{x:Null}" Margin="0,0,0.4,0" d:IsHidden="True" >
</ListBox>
</StackPanel>
</Border>
</Grid>
</TabItem>
</TabControl>
</Grid>
You need to align the ListBox
<ListBox x:Name="lb2Tab3" HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Top"
If that does not work then post more of your XAML
So the problem was related with the fact that there are several listBox one on top of the other. I thought that making them hidden was enough but when I painted the second listBox in black I saw that it was not starting from the top (see image).
So the solution was to set Visibility = Collapsed for all the listbox that are not in use.
Thanks to kirotab for putting me on the right path. Not sure if I can vote your comment.
<Models:VariableSizedGridView x:Name="SalesGridview" ItemsSource="{Binding SalesData}" Padding="50,10,0,1000" SelectionChanged="On_selectionChanged" ItemContainerStyle="{StaticResource SalesGridviewitemcustomStyle}" HorizontalAlignment="Left" VerticalAlignment="Top" >
<Models:VariableSizedGridView.ItemTemplate>
<DataTemplate>
<callisto:LiveTile>
<callisto:LiveTile.ItemTemplate>
<DataTemplate>
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<Grid.Background>
<SolidColorBrush Color="{Binding Background}"></SolidColorBrush>
</Grid.Background>
<Button Content="" FontFamily="Segoe UI Symbol" x:Name="flyoutcancel" Command="{Binding DeleteCommand}" Style="{StaticResource CustomSettingsButtonStyle}">
<Button.Flyout>
<Flyout x:Name="EditFlyout" Models:FlyoutHelpers.IsOpen="{Binding IsFlyoutOpen, Mode=TwoWay}" Models:FlyoutHelpers.Parent="{Binding ElementName=flyoutcancel}" Placement="Bottom">
<Grid Background="Transparent" VerticalAlignment="Top" HorizontalAlignment="Left" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" ></RowDefinition>
<RowDefinition Height="*" ></RowDefinition>
</Grid.RowDefinitions>
<Button Content="" Grid.Row="0" Foreground="White" Command="{Binding DataContext.CancelCommand, ElementName=SalesGridview}" CommandParameter="{Binding }" Style="{StaticResource CustomCancelPopupButtonStyle}" ></Button>
<StackPanel Width="165" Height="200" Grid.Row="1" Background="#334157">
<Button HorizontalAlignment="Left" Height="Auto" Margin="10,10,0,10" Style="{StaticResource CustomCancelPopupButtonStyle}" >
<Button.Content>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" >
<TextBlock Text="" FontSize="16" VerticalAlignment="Center" Style="{StaticResource SplitViewTextBlockStyle}"></TextBlock>
<TextBlock Text="Widget Settings" Margin="10,3,0,0" FontSize="14" VerticalAlignment="Center" FontFamily="Segeo UI Semibold" Style="{StaticResource SplitViewTextBlockStyle}"></TextBlock>
</StackPanel>
</Button.Content>
</Button>
<Button HorizontalAlignment="Left" Margin="10,0,0,0" Height="Auto" Command="{Binding DataContext.DeleteCommand, ElementName=SalesGridview}" CommandParameter="{Binding Id}" Style="{StaticResource CustomCancelPopupButtonStyle}" >
<Button.Content>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" >
<TextBlock Text="" FontSize="16" VerticalAlignment="Center" Style="{StaticResource SplitViewTextBlockStyle}"></TextBlock>
<TextBlock Text="Remove Widget" Margin="10,3,0,0" FontSize="14" VerticalAlignment="Center" FontFamily="Segeo UI Semibold" Style="{StaticResource SplitViewTextBlockStyle}"></TextBlock>
</StackPanel>
</Button.Content>
</Button>
</StackPanel>
</Grid>
</Flyout>
</Button.Flyout>
</Button>
</Grid>
</DataTemplate>
</callisto:LiveTile.ItemTemplate>
</callisto:LiveTile>
</DataTemplate>
</Models:VariableSizedGridView.ItemTemplate>
<Models:VariableSizedGridView.ItemsPanel>
<ItemsPanelTemplate>
<VariableSizedWrapGrid VerticalAlignment="Center" Orientation="Horizontal"
ItemHeight="90"
ItemWidth="90">
<VariableSizedWrapGrid.ChildrenTransitions>
<TransitionCollection>
<RepositionThemeTransition></RepositionThemeTransition>
<ReorderThemeTransition></ReorderThemeTransition>
</TransitionCollection>
</VariableSizedWrapGrid.ChildrenTransitions>
</VariableSizedWrapGrid>
</ItemsPanelTemplate>
</Models:VariableSizedGridView.ItemsPanel>
</Models:VariableSizedGridView>
am using above code for a variable sized gridview to show the item, in those items, some of items I want to display as live tiles.
How to bind the data for both Gridview and and Callisto Live tiles items.
Thanks in advance.
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.ColumnDefinitions/>
.....
</Grid>
And after insert your TextBlock to need column and row, for ex.:
<TextBlock Grid.Row="1" Grid.Column="1" />
I am creating a Windows Phone App. I am facing Xaml Parser exception. Following is my XAML code:
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.Resources>
<DataTemplate x:Name="PickerItemTemplate">
<StackPanel Orientation="Horizontal">
<Border Background="LightGreen" Width="34" Height="34">
<TextBlock Text="{Binding BloodGroupItems}" FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</StackPanel>
</DataTemplate>
<DataTemplate x:Name="PickerFullModeItemTemplate">
<StackPanel Orientation="Horizontal" Margin="16 21 0 20">
<TextBlock Text="{Binding BloodGroupItems}" Margin="16 0 0 0" FontSize="43" />
</StackPanel>
</DataTemplate>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
ListPicker:
<StackPanel Orientation="Horizontal">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock x:Name="BoolType" Margin="10,0,0,0" FontSize="30" Grid.Row="0"
Text="blood group"></TextBlock>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<toolkit:ListPicker x:Name="listPicker"
ItemTemplate="{StaticResource PickerItemTemplate}"
FullModeItemTemplate="{StaticResource PickerFullModeItemTemplate}"
FullModeHeader="Cities" SelectedIndex="2"
CacheMode="BitmapCache"
Header="blood" Width="114"/>
</StackPanel>
</Grid>
</StackPanel>
My code to pick the list items:
public ProfilePage()
{
InitializeComponent();
this.listPicker.ItemsSource = GetBloodItems();
}
public class BloodGroupDetail
{
public string BloodGroupItems { get; set; }
}
private List<BloodGroupDetail> GetBloodItems()
{
List<BloodGroupDetail> BloodDetails = new List<BloodGroupDetail>
{
new BloodGroupDetail { BloodGroupItems="A+"},
new BloodGroupDetail { BloodGroupItems="B+"},
new BloodGroupDetail { BloodGroupItems="AB+"},
new BloodGroupDetail { BloodGroupItems="O+"}
};
return BloodDetails;
}
I am getting the following exception:
I am very new in Windows Apps.
Updated code:
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.Resources>
<DataTemplate x:Name="PickerItemTemplate">
<StackPanel Orientation="Horizontal">
<Border Background="LightGreen" Width="34" Height="34">
<TextBlock Text="{Binding BloodGroupItems}" FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</StackPanel>
</DataTemplate>
<DataTemplate x:Name="PickerFullModeItemTemplate">
<StackPanel Orientation="Horizontal" Margin="16 21 0 20">
<TextBlock Text="{Binding BloodGroupItems}" Margin="16 0 0 0" FontSize="43" FontFamily="{StaticResource PhoneFontFamilyLight}"/>
</StackPanel>
</DataTemplate>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="user profile" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Grid x:Name="ProfilePanel" Margin="12,0,12,0">
<ScrollViewer>
<StackPanel Margin="0,4,16,0" Orientation="Vertical">
<TextBox x:Name="NameTB" Text="name" GotFocus="OnFocus" LostFocus="OnLostFocus" HorizontalAlignment="Left" Width="370" FontSize="22" Foreground="Gray" IsReadOnly="False" BorderThickness="0"/>
<TextBox x:Name="AgeTB" InputScope="Number" Text="age" GotFocus="OnFocus" LostFocus="OnLostFocus" HorizontalAlignment="Left" Width="370" FontSize="22" Foreground="Gray" IsReadOnly="False" BorderThickness="0"/>
<StackPanel Orientation="Horizontal">
<RadioButton x:Name="radioButtonsex1" Content="male" GroupName="Group1" Checked="RadioButtonGender_Checked" IsChecked="True" Width="150"/>
<RadioButton x:Name="radioButtonsex2" Content="female" GroupName="Group1" Checked="RadioButtonGender_Checked"/>
</StackPanel>
<TextBox x:Name="PincodeTB" InputScope="Number" Text="pincode" GotFocus="OnFocus" LostFocus="OnLostFocus" HorizontalAlignment="Left" Width="370" FontSize="22" Foreground="Gray" IsReadOnly="False" BorderThickness="0"/>
<TextBox x:Name="ContactTB" InputScope="Number" Text="contact no" GotFocus="OnFocus" LostFocus="OnLostFocus" HorizontalAlignment="Left" Width="370" FontSize="22" Foreground="Gray" IsReadOnly="False" BorderThickness="0"/>
<StackPanel Orientation="Horizontal">
<RadioButton x:Name="radioButtonvisible1" Content="public" GroupName="Group2" Checked="RadioButtonVisible_Checked" IsChecked="True" Width="150"/>
<RadioButton x:Name="radioButtonvisible2" Content="private" GroupName="Group2" Checked="RadioButtonVisible_Checked"/>
</StackPanel>
<toolkit:ListPicker x:Name="listPicker" ItemTemplate="{StaticResource PickerItemTemplate}" FullModeItemTemplate="{StaticResource PickerFullModeItemTemplate}" FullModeHeader="Cities" SelectedIndex="2" CacheMode="BitmapCache"
Header="blood group"/>
<StackPanel Orientation="Horizontal">
<RadioButton x:Name="radioButtonstatus1" Content="active" GroupName="Group3" Checked="RadioButtonStatus_Checked" IsChecked="True" Width="150"/>
<RadioButton x:Name="radioButtonstatus2" Content="inactive" GroupName="Group3" Checked="RadioButtonStatus_Checked"/>
</StackPanel>
<Button x:Name="btnSubmit" Content="Register" Tap="btnSubmit_Tap" Width="200"></Button>
</StackPanel>
</ScrollViewer>
</Grid>
</Grid>
</Grid>
The problem is that you gave a x:Name and not a x:Key to the template
Replace this:
<DataTemplate x:Name="PickerItemTemplate">
with this code:
<DataTemplate x:Key="PickerItemTemplate">
DataTemplates are accessed by their Key. If you also require the Name for some reason, you can also use both attributes at the same time.
I solved it.
Following is my XAML Page:
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.Resources>
<DataTemplate x:Name="PickerItemTemplate">
<StackPanel Orientation="Horizontal">
<Border Background="LightGreen" Width="34" Height="34">
<TextBlock Text="{Binding BloodGroupItems}" FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<TextBlock Text="{Binding BloodGroupItems}" Margin="12 0 0 0"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Name="PickerFullModeItemTemplate">
<StackPanel Orientation="Horizontal" Margin="16 21 0 20">
<TextBlock Text="{Binding BloodGroupItems}" Margin="16 0 0 0" FontSize="43" FontFamily="{StaticResource PhoneFontFamilyLight}"/>
</StackPanel>
</DataTemplate>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="user profile" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Grid x:Name="ProfilePanel" Margin="12,0,12,0">
<ScrollViewer>
<StackPanel Margin="0,4,16,0" Orientation="Vertical">
<TextBox x:Name="NameTB" Text="name" GotFocus="OnFocus" LostFocus="OnLostFocus" HorizontalAlignment="Left" Width="370" FontSize="22" Foreground="Gray" IsReadOnly="False" BorderThickness="0"/>
<TextBox x:Name="AgeTB" InputScope="Number" Text="age" GotFocus="OnFocus" LostFocus="OnLostFocus" HorizontalAlignment="Left" Width="370" FontSize="22" Foreground="Gray" IsReadOnly="False" BorderThickness="0"/>
<StackPanel Orientation="Horizontal">
<RadioButton x:Name="radioButtonsex1" Content="male" GroupName="Group1" Checked="RadioButtonGender_Checked" IsChecked="True" Width="150"/>
<RadioButton x:Name="radioButtonsex2" Content="female" GroupName="Group1" Checked="RadioButtonGender_Checked"/>
</StackPanel>
<TextBox x:Name="PincodeTB" InputScope="Number" Text="pincode" GotFocus="OnFocus" LostFocus="OnLostFocus" HorizontalAlignment="Left" Width="370" FontSize="22" Foreground="Gray" IsReadOnly="False" BorderThickness="0"/>
<TextBox x:Name="ContactTB" InputScope="Number" Text="contact no" GotFocus="OnFocus" LostFocus="OnLostFocus" HorizontalAlignment="Left" Width="370" FontSize="22" Foreground="Gray" IsReadOnly="False" BorderThickness="0"/>
<StackPanel Orientation="Horizontal">
<RadioButton x:Name="radioButtonvisible1" Content="public" GroupName="Group2" Checked="RadioButtonVisible_Checked" IsChecked="True" Width="150"/>
<RadioButton x:Name="radioButtonvisible2" Content="private" GroupName="Group2" Checked="RadioButtonVisible_Checked"/>
</StackPanel>
<toolkit:ListPicker x:Name="listPicker" ItemTemplate="{StaticResource PickerItemTemplate}"
FullModeItemTemplate="{StaticResource PickerFullModeItemTemplate}" FullModeHeader="Cities" SelectedIndex="2" CacheMode="BitmapCache"
Header="blood group" />
<StackPanel Orientation="Horizontal">
<RadioButton x:Name="radioButtonstatus1" Content="active" GroupName="Group3" Checked="RadioButtonStatus_Checked" IsChecked="True" Width="150"/>
<RadioButton x:Name="radioButtonstatus2" Content="inactive" GroupName="Group3" Checked="RadioButtonStatus_Checked"/>
</StackPanel>
<Button x:Name="btnSubmit" Content="Register" Tap="btnSubmit_Tap" Width="200"></Button>
</StackPanel>
</ScrollViewer>
</Grid>
</Grid>
My Code:
public ProfilePage()
{
InitializeComponent();
listPicker.SetValue(Microsoft.Phone.Controls.ListPicker.ItemCountThresholdProperty, 3);
List<BloodGroupDetail> source = new List<BloodGroupDetail>();
source.Add(new BloodGroupDetail() { BloodGroupItems = "A+" });
source.Add(new BloodGroupDetail() { BloodGroupItems = "B+" });
source.Add(new BloodGroupDetail() { BloodGroupItems = "O+" });
source.Add(new BloodGroupDetail() { BloodGroupItems = "AB+" });
this.listPicker.ItemsSource = source;
}
public class BloodGroupDetail
{
public string BloodGroupItems { get; set; }
}
I have the following problem:
<DataTemplate x:Key="OrganisationsItemTemplate">
<StackPanel VerticalAlignment="Top" Margin="5,0,0,0">
<Button Command="{Binding Path=DataContext.LoadSpacesCommand, ElementName=OrganisationList}" CommandParameter="{Binding}" Padding="-5,0,-5,-5" Margin="-7,-12,-7,-7" Height="auto" BorderThickness="0" HorizontalAlignment="Left" VerticalAlignment="Stretch" HorizontalContentAlignment="Left" UseLayoutRounding="True" FontSize="0.01">
<Grid Margin="0,0,5,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="67"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Background="Transparent">
<Border Background="White" BorderThickness="0" Width="62" Height="62" HorizontalAlignment="Left" Margin="0,0,0,5">
<Image Source="{Binding image.thumbnail_link}" Width="62" Height="62"></Image>
</Border>
</StackPanel>
<StackPanel Grid.Column="1" VerticalAlignment="Center" Background="Transparent">
<!--<TextBlock Text="{Binding name}" HorizontalAlignment="Left" FontSize="30" VerticalAlignment="Center" Margin="0,0,0,5" />-->
<phone:LongListSelector x:Name="SpacesList"
Background="Transparent"
ItemTemplate="{StaticResource SpacesTemplate }"
ItemsSource="{Binding spaces}"
Margin="40,0,0,96"
LayoutMode="List"
HideEmptyGroups="True"
IsGroupingEnabled="False" VerticalContentAlignment="Top">
</phone:LongListSelector>
</StackPanel>
</Grid>
</Button>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="SpacesTemplate">
<Border Background="Transparent" Padding="5,0,0,5">
<Border Background="{StaticResource PhoneAccentBrush}" BorderBrush="{StaticResource PhoneAccentBrush}" BorderThickness="2" Width="62"
Height="62" Margin="0,0,18,0" HorizontalAlignment="Left">
<TextBlock Text="{Binding name}" Foreground="{StaticResource PhoneForegroundBrush}" FontSize="48" Padding="6"
FontFamily="{StaticResource PhoneFontFamilySemiLight}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
</Border>
</Border>
</DataTemplate>
In my data template I am placing LongListselector... which also needs a template. but the SpacesTemplate that is defined outside the current datatemplate cannot be seen. any ideas how to reference the datatemplate "SpacesTemplate" from within the datatemplate "OrganisationsItemTemplate"
Xaml is read top down, if you want to use SpacesTemplate inside OrganisationsItemTemplate you will have to put SpacesTemplate before OrganisationsItemTemplate in the Xaml