I've a strange problem with xaml.
Visual studio for wp tell me that the xaml is not valid but when I execute the app it works fine.
<phone:PhoneApplicationPage
x:Class="Friends_And_Money.ContList"
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"
xmlns:local="clr-namespace:Friends_And_Money"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot è la griglia radice in cui viene inserito tutto il contenuto della pagina-->
<phone:PhoneApplicationPage.Resources>
<local:ContactPictureConverter x:Key="ImageConverter" />
<DataTemplate x:Key="AddrBookGroupHeaderTemplate">
<Border Background="Transparent" Padding="5">
<Border Background="{StaticResource PhoneAccentBrush}" BorderBrush="{StaticResource PhoneAccentBrush}" BorderThickness="2" Width="62"
Height="62" Margin="0,0,18,0" HorizontalAlignment="Left">
<TextBlock Text="{Binding Key}" Foreground="{StaticResource PhoneForegroundBrush}" FontSize="48" Padding="6"
FontFamily="{StaticResource PhoneFontFamilySemiLight}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
</Border>
</Border>
</DataTemplate>
<phone:JumpListItemBackgroundConverter x:Key="BackgroundConverter"/>
<phone:JumpListItemForegroundConverter x:Key="ForegroundConverter"/>
<Style x:Key="AddrBookJumpListStyle" TargetType="phone:LongListSelector">
<Setter Property="GridCellSize" Value="113,113"/>
<Setter Property="LayoutMode" Value="Grid" />
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<Border Background="{Binding Converter={StaticResource BackgroundConverter}}" Width="113" Height="113" Margin="6" >
<TextBlock Text="{Binding Key}" FontFamily="{StaticResource PhoneFontFamilySemiBold}" FontSize="48" Padding="6"
Foreground="{Binding Converter={StaticResource ForegroundConverter}}" VerticalAlignment="Center"/>
</Border>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
<DataTemplate x:Key="AddrBookItemTemplate">
<StackPanel VerticalAlignment="Top" Margin="0,5,0,5">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5" ></ColumnDefinition>
<ColumnDefinition Width="auto" ></ColumnDefinition>
<ColumnDefinition Width="5" ></ColumnDefinition>
<ColumnDefinition Width="auto" ></ColumnDefinition>
</Grid.ColumnDefinitions>
<Image Source="{Binding Photo, Converter={StaticResource ImageConverter}}" Grid.Column="1" Width="62" Height="62" Stretch="Fill" />
<TextBlock Grid.Column="3" FontWeight="Light" FontSize="40" Text="{Binding FirstName}" />
</Grid>
</StackPanel>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contiene il nome dell'applicazione e il titolo della pagina-->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
<TextBlock Text="{Binding Path=LocalizedResources.ContactTitle, Source={StaticResource LocalizedStrings}}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - inserire ulteriore contenuto qui-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<phone:LongListSelector x:Name="LongList"
Background="Transparent"
GroupHeaderTemplate="{StaticResource AddrBookGroupHeaderTemplate}"
ItemTemplate="{StaticResource AddrBookItemTemplate}"
JumpListStyle="{StaticResource AddrBookJumpListStyle}"
LayoutMode="List"
IsGroupingEnabled="true"
HideEmptyGroups ="true" />
</Grid>
</Grid>
</phone:PhoneApplicationPage>
I've followed the tutorial (with the difference of a longlistselector) from here : [http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh286418(v=vs.105).aspx][1]
How I say all works fine, longlistselector show me images and contact's name.
Struct to show:
namespace Friends_And_Money
{
class ContactStruct
{
public string FirstName
{
get;
set;
}
public WriteableBitmap Photo
{
get;
set;
}
public ContactStruct(string name, WriteableBitmap photo)
{
this.FirstName = name;
this.Photo = photo;
}
}
}
Thanks to every one that help.
New details:
The error is signed in datatemplate AddrBookItemTemplate and I've noted that if I leave image source attribute the error disappear.
So seems be something with the binding.
Visual studio for wp tell me that the xaml is not valid but when I execute the app it works fine.
Please ignore the designer. It's rather moody.
It's maybe a bad copy / paste, but your first element (<phone:PhoneApplicationPage>) is not close.
Related
I am new and learning WPF. I am making a demo project to learn the working of binding and dependency properties. To make it easy to understand I briefly explain this project. In solution, I have three projects. Two projects are user control and one is the main application.
This is user control for the child page
<UserControl x:Class="DefectTracking.DefectTrace"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="1200"
Grid.IsSharedSizeScope="True"
Loaded="ElementGeladen"
Name="Self">
<UserControl.Resources>
<ResourceDictionary Source="Resources.xaml" />
</UserControl.Resources>
<UserControl.Style>
<Style TargetType="{x:Type UserControl}">
<Setter Property="Background" Value="{StaticResource Hintergrundfarbe}"/>
</Style>
</UserControl.Style>
<Grid DataContext="{Binding ElementName=Self}" Margin="4">
<FrameworkElement x:Name="ProxyElement"/>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<!--#region Kopfzeile -->
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="Ergebnisse"/>
<ColumnDefinition SharedSizeGroup="Name"/>
<ColumnDefinition SharedSizeGroup="Folgefehler" Width="*"/>
<ColumnDefinition SharedSizeGroup="Fehler"/>
<ColumnDefinition SharedSizeGroup="Aktiviert"/>
</Grid.ColumnDefinitions>
<TextBox Grid.Column="2" Style="{StaticResource FolgefehlerStil}" Text="FF" />
<TextBox Grid.Column="3" Style="{StaticResource FehlerStil}" Text="Fehler"/>
<TextBox Grid.Column="4" Style="{StaticResource FehlerStil}" Text="Aktiviert"/>
</Grid>
<!--#endregion-->
<!--#region Prüfung -->
<ItemsControl Grid.Row="1" ItemsSource="{Binding Prüfungen}" Name="Prüfungselement">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Background="Black">
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="Ergebnisse"/>
<ColumnDefinition SharedSizeGroup="Name"/>
<ColumnDefinition SharedSizeGroup="Folgefehler"/>
<ColumnDefinition SharedSizeGroup="Fehler"/>
<ColumnDefinition SharedSizeGroup="Aktiviert"/>
</Grid.ColumnDefinitions>
<!--#region Ergebnisse -->
<ItemsControl Grid.Column="0" ItemsSource="{Binding Ergebnisse}" Style="{StaticResource ErgebnisStil}" Background="Black" MouseDoubleClick="ItemsControl_MouseDoubleClick">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<DockPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
<!--#endregion-->
<!--#region Tabelle -->
<TextBox Grid.Column="1" Margin="10,0" MinWidth="50" Text="{Binding Path=Name}" Style="{StaticResource PrüfungsnameStil}"/>
<TextBox Grid.Column="2" MinWidth="40" Text="{Binding Path=Folgefehler}" Style="{StaticResource FolgefehlerStil}"/>
<TextBox Grid.Column="3" MinWidth="60" Text="{Binding Path=Fehler}" Style="{StaticResource FehlerStil}" IsReadOnly="True"/>
<CheckBox Grid.Column="4" MinWidth="40" IsChecked="{Binding Status, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="5,0,0,0"/>
<!--#endregion-->
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<!--#endregion-->
</Grid>
<!--#region Folgefehlerschieber -->
<Canvas>
<Thumb DragDelta="LinealVerschieben" Canvas.Left="450" Canvas.Top="0">
<Thumb.Template>
<ControlTemplate>
<Grid>
<Line X1="0" Y1="0" X2="0"
Y2="{Binding ActualHeight, Source={x:Reference ProxyElement}}"
Canvas.ZIndex="2"
Style="{StaticResource LinealStil}" Cursor="Hand">
</Line>
<Rectangle Width="11" Margin="0,0,20,0"
Height="{Binding ActualHeight, Source={x:Reference ProxyElement}}"
Style="{StaticResource AnfasserStil}" Cursor="Hand">
<Rectangle.RenderTransform>
<TranslateTransform X="-5" Y="0"/>
</Rectangle.RenderTransform>
</Rectangle>
<Label Style="{StaticResource LabelStil}" Content="{Binding Linealposition}"/>
</Grid>
</ControlTemplate>
</Thumb.Template>
</Thumb>
</Canvas>
<!--#endregion-->
</Grid>
</UserControl>
I am just testing
<CheckBox Grid.Column="4" MinWidth="40" IsChecked="{Binding Status, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="5,0,0,0"/>
This is the user control for the child page
<UserControl x:Class="Demo.View.Dashboard"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Demo.View"
xmlns:vm="clr-namespace:Demo.ViewModel"
xmlns:dt="clr-namespace:DefectTracking;assembly=DefectTrackingControl"
mc:Ignorable="d"
d:DesignHeight="900" d:DesignWidth="1600"
>
<UserControl.DataContext>
<vm:DashboardViewModel/>
</UserControl.DataContext>
<UserControl.Resources>
<vm:BindingProxy x:Key="proxy" Data="{Binding}"/>
<dt:Prüfung x:Key="www"/>
</UserControl.Resources>
<Grid Background="White">
<dt:DefectTrace Margin="0,0,-321,-91">
<dt:DefectTrace.Prüfungen>
<dt:Prüfung
Status="{Binding Path=status}" />
<dt:Prüfung Name="Stabseite" />
<dt:Prüfung Name="Stosskappe" />
<dt:Prüfung Name="Druckbild"
/>
<dt:Prüfung Name="Oberfläche"
/>
</dt:DefectTrace.Prüfungen>
</dt:DefectTrace>
<CheckBox IsChecked="{Binding state, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="100,100,100,10">Test check box</CheckBox>
</Grid>
</UserControl>
Property definition which I want to bind with checkbox but it's not propagating into a user control. If I just set true and false then it works but if I bind then it doesn't work.
Any help would be highly appreciated
I believe the problem here is
<UserControl.DataContext>
<vm:DashboardViewModel/>
</UserControl.DataContext>
because that basically means using a new instance of DashboardViewModel for this particular view, so I would assume that in your code somewhere you are using a different instance of this view model in which changing the value of Status does not really matter.
If the reason is what I think it is and you want to enhance your user comfort while developing XAML files and using this to help the compiler to know the types you can use the d:DataContext something like:
d:DataContext={x:Type vm:DashboardViewModel}
(UPDATE: even without DEVEXPRESS controls, the same behavior is observed. So, I tested it with a couple textBlocks inside of a Grid...)
I am new to WPF development and I am using Windows Template Studio on VS 2019 (net core 3.1).
I am also using DEVEXPRESS.
I am wondering why I am losing the default MetroWindow theme in a user control when I add a custom TitleTemplate to the ShellWindow.xaml.
This is likely something very simple that I am not doing properly...
Repro steps:
1 - Create a default WPF Windows Template Studio Project. Select Navigation Pane as the Project type.
2 - Add a second blank page.
3 - Add DevExpress.WPF to the project (Not needed to duplicate).
4 - Create a simple user control
<UserControl x:Class="NoDevExpresssTitleTemplate.Views.TestUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:NoDevExpresssTitleTemplate.Views"
xmlns:dxlc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<dxlc:LayoutControl >
<dxlc:LayoutGroup>
<dxlc:LayoutItem Label="test1:" Width="150" VerticalAlignment="Center" Margin="20,0,0,0">
<dxe:TextEdit EditValue="Test1"/>
</dxlc:LayoutItem>
<dxlc:LayoutItem Label="test2:" Width="150" VerticalAlignment="Center" Margin="20,0,0,0">
<d:TextBox Text="test2"/>
</dxlc:LayoutItem>
</dxlc:LayoutGroup>
</dxlc:LayoutControl>
</Grid>
5 - Use the user control on the second blank page created,
<Page
x:Class="NoDevExpresssTitleTemplate.Views.SearchPage"
Style="{DynamicResource MahApps.Styles.Page}"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:properties="clr-namespace:NoDevExpresssTitleTemplate.Properties"
xmlns:views="clr-namespace:NoDevExpresssTitleTemplate.Views"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="48" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock
Style="{StaticResource PageTitleStyle}"
Margin="{StaticResource MediumLeftMargin}"
Text="{x:Static properties:Resources.SearchPageTitle}" />
<Grid
Grid.Row="1"
Margin="{StaticResource MediumLeftRightMargin}"
Background="{DynamicResource MahApps.Brushes.Gray10}">
<!--
The Mahapps Gray10 color represents where you should place your content.
Place your content here.
-->
<views:TestUserControl></views:TestUserControl>
</Grid>
</Grid>
6 - Update the ShellWindow.xaml, including the TitleTemplate,
<controls:MetroWindow
x:Class="NoDevExpresssTitleTemplate.Views.ShellWindow"
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:dxlc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:properties="clr-namespace:NoDevExpresssTitleTemplate.Properties"
xmlns:templateSelectors="clr-namespace:NoDevExpresssTitleTemplate.TemplateSelectors"
Style="{StaticResource CustomMetroWindow}"
mc:Ignorable="d"
MinWidth="500"
MinHeight="350"
Title="{x:Static properties:Resources.AppDisplayName}">
<controls:MetroWindow.TitleTemplate>
<DataTemplate>
<dxlc:LayoutControl>
<dxlc:LayoutGroup Orientation="Vertical" Height="50" >
<TextBlock Text="{TemplateBinding Content}"
TextTrimming="CharacterEllipsis"
VerticalAlignment="Center"
Margin="8 -1 8 0"
FontWeight="Light"
FontSize="{DynamicResource WindowTitleFontSize}"
FontFamily="{DynamicResource HeaderFontFamily}" />
<TextBlock Text="{TemplateBinding Content}"
TextTrimming="CharacterEllipsis"
VerticalAlignment="Center"
Margin="8 -1 8 0"
FontWeight="Light"
FontSize="{DynamicResource WindowTitleFontSize}"
FontFamily="{DynamicResource HeaderFontFamily}" />
</dxlc:LayoutGroup>
</dxlc:LayoutControl>
</DataTemplate>
</controls:MetroWindow.TitleTemplate>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<i:InvokeCommandAction Command="{Binding LoadedCommand}" />
</i:EventTrigger>
<i:EventTrigger EventName="Unloaded">
<i:InvokeCommandAction Command="{Binding UnloadedCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<controls:MetroWindow.LeftWindowCommands>
<controls:WindowCommands>
<Button
Width="{Binding ElementName=hamburgerMenu, Path=CompactPaneLength}"
AutomationProperties.Name="{x:Static properties:Resources.ShellGoBackButton}"
ToolTip="{x:Static properties:Resources.ShellGoBackButton}"
Command="{Binding GoBackCommand}">
<TextBlock
Text=""
FontSize="14"
FontFamily="Segoe MDL2 Assets"
AutomationProperties.Name="{x:Static properties:Resources.ShellGoBackButton}" />
</Button>
</controls:WindowCommands>
</controls:MetroWindow.LeftWindowCommands>
<controls:MetroWindow.Resources>
<templateSelectors:MenuItemTemplateSelector
x:Key="MenuItemTemplateSelector">
<templateSelectors:MenuItemTemplateSelector.GlyphDataTemplate>
<DataTemplate DataType="{x:Type controls:HamburgerMenuGlyphItem}">
<Grid Height="48">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="48" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="0"
FontSize="16"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="Segoe MDL2 Assets"
Text="{Binding Glyph}"
ToolTip="{Binding Label}" />
<TextBlock
Grid.Column="1"
VerticalAlignment="Center"
FontSize="16"
Text="{Binding Label}" />
</Grid>
</DataTemplate>
</templateSelectors:MenuItemTemplateSelector.GlyphDataTemplate>
<templateSelectors:MenuItemTemplateSelector.ImageDataTemplate>
<DataTemplate DataType="{x:Type controls:HamburgerMenuImageItem}">
<Grid Height="48">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="48" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Ellipse
Grid.Column="0"
Width="24"
Height="24"
HorizontalAlignment="Center"
VerticalAlignment="Center"
ToolTip="{Binding Label}">
<Ellipse.Fill>
<ImageBrush ImageSource="{Binding Thumbnail}" />
</Ellipse.Fill>
</Ellipse>
<TextBlock
Grid.Column="1"
VerticalAlignment="Center"
FontSize="16"
Text="{Binding Label}" />
</Grid>
</DataTemplate>
</templateSelectors:MenuItemTemplateSelector.ImageDataTemplate>
</templateSelectors:MenuItemTemplateSelector>
</controls:MetroWindow.Resources>
<controls:MetroWindow.Content>
<controls:HamburgerMenu
x:Name="hamburgerMenu"
HamburgerButtonName="{x:Static properties:Resources.ShellHamburgerButtonName}"
IsPaneOpen="False"
DisplayMode="CompactInline"
ItemsSource="{Binding MenuItems}"
SelectedItem="{Binding SelectedMenuItem}"
ItemCommand="{Binding MenuItemInvokedCommand}"
ItemTemplateSelector="{StaticResource MenuItemTemplateSelector}">
<controls:HamburgerMenu.Content>
<Frame
x:Name="shellFrame"
Grid.Row="1"
NavigationUIVisibility="Hidden"
Focusable="False" />
</controls:HamburgerMenu.Content>
</controls:HamburgerMenu>
</controls:MetroWindow.Content></controls:MetroWindow>
The default Light.Blue theme/style is lost,
When I run my C# UWP app in debug mode with Visual Studio it works fine, however after trying to Create an App Package, I get an error during the build:
Cannot implicitly convert type 'Windows.UI.Xaml.Controls.Button' to 'Windows.UI.Xaml.Controls.AppBarButton'. An explicit conversion exists (are you missing a cast?)
I don't actually have any Buttons in the xaml code, they're all AppBarButtons. Can anyone see what I've got wrong? The Xaml is below.
<Page
x:Class="Sheet_Music_Reader.Views.ScoreViewer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Sheet_Music_Reader.Views"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:muxc="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
mc:Ignorable="d">
<Grid Margin="0,-125,0,0" Background="{ThemeResource AcrylicInAppFillColorDefaultBrush}">
<CommandBar DefaultLabelPosition="Right" Height="42" HorizontalContentAlignment="Left" >
<CommandBar.Content>
<AppBarButton FocusVisualPrimaryThickness="0" FocusVisualSecondaryThickness="0" VerticalAlignment="Top" HorizontalAlignment="Left" Icon="Back" x:Name="BackButton" ToolTipService.ToolTip="Back" Click="BackButton_Click"/>
</CommandBar.Content>
<AppBarSeparator/>
<AppBarElementContainer>
<InkToolbar x:Name="inkToolbar" VerticalAlignment="Center" HorizontalAlignment="Left" Orientation="Horizontal" TargetInkCanvas="{x:Bind inkCanvasA}">
<InkToolbarCustomToggleButton
x:Name="toggleButton"
Click="CustomToggle_Click"
ToolTipService.ToolTip="Touch Writing">
<SymbolIcon Symbol="{x:Bind TouchWritingIcon}"/>
</InkToolbarCustomToggleButton>
</InkToolbar>
</AppBarElementContainer>
<AppBarSeparator/>
<AppBarElementContainer VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Margin="0,0,10,0" VerticalAlignment="Center" Padding="10,0,0,0">Go to page:</TextBlock>
<TextBox FocusEngaged="GoToTextBox_FocusEngaged" AllowFocusWhenDisabled="True" AllowFocusOnInteraction="True" x:Name="GoToTextBox" BorderThickness="0" VerticalAlignment="Center" KeyDown="GoToTextBox_KeyDown" InputScope="Number" IsHitTestVisible="True" IsEnabled="True"/>
<AppBarButton Width="40" Height="45" Click="GoToPage" VerticalAlignment="Center" BorderThickness="0" Background="Transparent">🡢</AppBarButton>
</StackPanel>
</AppBarElementContainer>
<AppBarSeparator/>
<AppBarButton Label="Fullscreen" Icon="FullScreen" x:Name="FullscreenButton" ToolTipService.ToolTip="Fullscreen" Click="FullscreenButton_Click"/>
<AppBarSeparator/>
<AppBarButton Label="Bookmarks" Icon="Bookmarks" x:Name="BookMarksButton" ToolTipService.ToolTip="Bookmarks">
<AppBarButton.Flyout>
<Flyout Placement="Bottom">
<StackPanel Margin="0,20,0,0" Background="Transparent">
<StackPanel x:Name="bookmarkstackpanel" Margin="10" Background="Transparent">
<TextBlock x:Name="nobookmarkmessage" Text="You have no bookmarks." />
<StackPanel x:Name="bookmarkstacker" Orientation="Horizontal" Background="Transparent">
<ListView x:Name="bookmarkslist" Margin="0,0,5,0">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<ContentPresenter/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
</ListView>
<ListView x:Name="bookmarkslistdeleter" Width="53">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<ContentPresenter/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
</ListView>
</StackPanel>
</StackPanel>
<AppBarButton Content="Create Bookmark" Width="140" BorderThickness="1" BorderBrush="gray" Height="50" HorizontalAlignment="Center" Margin="30,0,30,0" FontSize="18" Click="NewBookmarksButton_Click"></AppBarButton>
</StackPanel>
</Flyout>
</AppBarButton.Flyout>
</AppBarButton>
</CommandBar>
<ProgressRing x:Name="LoadingIndicator" Height="100" Width="100"/>
<TextBlock x:Name="LoadingText" Text="Opening PDF" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" Margin="0,180,0,0"/>
<TextBlock x:Name="LoadingText2" Text="Large documents may take a moment to open for the first time" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16" Margin="0,270,0,0"/>
<AppBarButton Width="0" Height="0" x:Name="focusremover"></AppBarButton>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="0,45,0,0" Grid.Row="1" x:Name="DoubleGrid">
<ScrollViewer x:Name="landscapescroller" ZoomMode="Enabled" MinZoomFactor="1" MaxZoomFactor="7" HorizontalScrollBarVisibility="Visible" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
VerticalScrollBarVisibility="Visible">
<Grid x:Name="biggergrid">
<Grid x:Name="landscapeEnclosingGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
</Grid.RowDefinitions>
<Grid Grid.Column="0" Grid.Row="0" Margin="0,0,0,0" x:Name="leftimagegrid">
<Image x:Name="leftimage" VerticalAlignment="Center" Source="/Assets/enScore-logo-grey-large.png" HorizontalAlignment="Right"/>
</Grid>
<Grid Grid.Column="1" Grid.Row="0" Margin="0,0,0,0">
<Image x:Name="rightimage" VerticalAlignment="Center" Source="/Assets/enScore-logo-grey-large.png" HorizontalAlignment="Left"/>
</Grid>
</Grid>
<InkCanvas x:Name="inkCanvasA" />
</Grid>
</ScrollViewer>
</Grid>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" x:Name="SingleImage" Margin="-1000,45,-1000,0" Grid.Row="1">
<ScrollViewer ZoomMode="Enabled" MinZoomFactor="1" MaxZoomFactor="7" HorizontalScrollBarVisibility="Visible" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
VerticalScrollBarVisibility="Visible" Name="singlescroller">
<Grid x:Name="biggergridtwo">
<Grid x:Name="portraitEnclosingGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
</Grid.RowDefinitions>
<Grid Margin="0,0,0,0" Grid.Column="0" Grid.Row="0">
<Image x:Name="SingleImagefield" VerticalAlignment="Center" Source="/Assets/enScore-logo-grey-large.png" HorizontalAlignment="Center"/>
</Grid>
</Grid>
<ScrollViewer MinZoomFactor="2" MaxZoomFactor="2" HorizontalScrollMode="Disabled" ZoomMode="Disabled" VerticalScrollMode="Disabled">
<InkCanvas x:Name="inkCanvasB" Width="4000"/>
</ScrollViewer>
</Grid>
</ScrollViewer>
</Grid>
<RelativePanel x:Name="PageTurningCanvas" Margin="0,40,0,0">
<Grid PointerPressed="TurnPageLeftButton_PointerPressed" PointerEntered="Grid_PointerEntered" PointerMoved="Grid_PointerEntered" x:Name="TurnPageLeftButton" RelativePanel.AlignLeftWithPanel="True" RelativePanel.AlignBottomWithPanel="True" RelativePanel.AlignTopWithPanel="True" Width="100" Opacity="0" VerticalAlignment="Center" HorizontalAlignment="Left" Background="Transparent"/>
<Grid PointerPressed="TurnPageRightButton_PointerPressed" PointerEntered="Grid_PointerEntered" PointerMoved="Grid_PointerEntered" x:Name="TurnPageRightButton" RelativePanel.AlignRightWithPanel="True" RelativePanel.AlignBottomWithPanel="True" RelativePanel.AlignTopWithPanel="True" Width="100" Opacity="0" VerticalAlignment="Center" HorizontalAlignment="Right" Background="Transparent"/>
</RelativePanel>
</Grid>
</Page>
I have added a ScrollViewer object on my application page and I have added many control objects on the ScrollViewer object but the end-user using the app can not view all the elements because the Scroll does not scroll low enough, and the page keeps returning to it's original position before the user has the opportunity to enter any information.
My XAML code is here:
<phone:PhoneApplicationPage
x:Class="ChronosMobile.PhoneApp.OrçamentoPage"
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" Margin="0,0,0,-153">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid x:Name="LayoutRoot1" Background="#FF4F8899" Margin="0,0,0,59">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ScrollViewer Margin="-10,0,10,169">
<StackPanel Height="916">
<TextBox x:Name="txtNomeCliente" Height="Auto" TextWrapping="Wrap"
Text="" Background="White" BorderBrush="White" IsReadOnly="True"/>
<Button x:Name="BotaoCatalogo" Content="Catálogo"
Width="Auto" Height="80" VerticalAlignment="Top" Background="#FF3FAACA" BorderBrush="#FF3FAACA" Click="BotaoCatalogo_Click"/>
<Button x:Name="BotaoItens" Content="Itens"
Width="Auto" Height="80" VerticalAlignment="Top" Background="#FF3FAACA" BorderBrush="#FF3FAACA" Click="BotaoItens_Click"/>
<Grid Background="#FF0F3B48" Margin="12,0,12,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0"
VerticalAlignment="Center"
Orientation="Horizontal"
Margin="5">
<TextBlock Text="Qtde. de Itens:"
FontSize="{StaticResource PhoneFontSizeMedium}"/>
<TextBlock x:Name="lblQuantidadeProdutos" Text="0" Margin="10,0,0,0" FontSize="{StaticResource PhoneFontSizeMedium}" Width="43"/>
</StackPanel>
<StackPanel Grid.Column="1"
VerticalAlignment="Center"
HorizontalAlignment="Right"
Orientation="Horizontal"
Margin="2">
<TextBlock x:Name="lblValorTotal" FontSize="{StaticResource PhoneFontSizeMedium}"/>
</StackPanel>
</Grid>
<Button x:Name="BotaoPagamentos" Content="Adicionar Pagamento"
Width="Auto" Height="80" VerticalAlignment="Top" Background="#FF3FAACA" BorderBrush="#FF3FAACA" Click="BotaoPagamentos_Click"/>
<ListBox x:Name="ListaPagamentos" ItemsSource="{Binding ListaPagamentos}"/>
<ListBox x:Name="ListaEntrega" ItemsSource="{Binding ListaEntrega}"/>
<Grid Background="#FF0F3B48" Margin="12,0,12,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0"
VerticalAlignment="Center"
Margin="5">
<TextBlock
FontSize="16" FontWeight="Bold">
<Run FontWeight="Normal" Text="Forma de pagamento: A vista"/>
</TextBlock>
<TextBlock
FontSize="16">
<Run Text="Parcela(s):"/>
<Run Text=" "/>
<Run Text="1"/>
</TextBlock>
<TextBlock
FontSize="16">
<Run Text="Vencimento"/>
<Run Text=":"/>
<Run Text=" "/>
<Run Text="25/05/2013"/>
</TextBlock>
</StackPanel>
<StackPanel Grid.Column="1"
VerticalAlignment="Center"
HorizontalAlignment="Right"
Margin="2">
<TextBlock
FontSize="{StaticResource PhoneFontSizeMedium}" Margin="0">
<Run Text=" "/>
<Run Text="Valor"/>
</TextBlock>
<TextBlock Text="R$ 399,00"
FontSize="{StaticResource PhoneFontSizeMedium}"/>
</StackPanel>
</Grid>
<Button x:Name="cmdEntrega" Content="Entrega" Width="Auto" Height="80" VerticalAlignment="Top" Background="#FF3FAACA" BorderBrush="#FF3FAACA" Click="BotaoEntrega_Click"/>
<Grid Background="#FF0F3B48" Margin="12,0,12,0" Height="50">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="4*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0"
VerticalAlignment="Center"
Orientation="Horizontal"
Margin="5,12,81,0" Height="38" Grid.ColumnSpan="2">
<TextBlock x:Name="lblTransportadora"
FontSize="{StaticResource PhoneFontSizeMedium}" Width="149">
<Run FontSize="20" Text="Transportadora"/>
<Run FontSize="20" Text=":"/>
</TextBlock>
</StackPanel>
</Grid>
<Grid Height="13" Width="437"/>
<Grid Background="#FF0F3B48" Margin="12,0,12,0" Height="135">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="4*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0"
VerticalAlignment="Center"
Orientation="Horizontal"
Margin="5,12,81,0" Height="38" Grid.ColumnSpan="2">
<TextBlock x:Name="lblTransportadora1"
FontSize="{StaticResource PhoneFontSizeMedium}" Width="58" Margin="0,-2,0,12">
<Run FontSize="20" Text="Rua:"/>
</TextBlock>
</StackPanel>
<TextBlock FontSize="{StaticResource PhoneFontSizeMedium}" Margin="5,11,128,85">
<Run FontSize="20" Text="Descrição:"/>
</TextBlock>
<TextBlock FontSize="{StaticResource PhoneFontSizeMedium}" Margin="5,96,165,10">
<Run FontSize="20" Text="Cidade:"/>
</TextBlock>
<TextBlock x:Name="lblDescricao" Grid.ColumnSpan="2" HorizontalAlignment="Left" Height="26" Margin="113,16,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="315"/>
<TextBlock x:Name="lblRua" Grid.ColumnSpan="2" HorizontalAlignment="Left" Height="26" Margin="113,57,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="317"/>
<TextBlock x:Name="lblCidade" Grid.ColumnSpan="2" HorizontalAlignment="Left" Height="26" Margin="113,99,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="319"/>
</Grid>
<Grid Height="20" Width="437"/>
<TextBlock Text="Informações Adicionais:" Margin="15,10,0,0"/>
<TextBox x:Name="TxtInfoAdicional" Height="Auto" TextWrapping="Wrap"
Text="{Binding InfoAdicional, Mode=TwoWay}" Background="White" BorderBrush="White"/>
<Button x:Name="BotaoFinalizar" Content="Salvar Orçamento"
Width="238" Height="80" VerticalAlignment="Top"
HorizontalAlignment="Right" BorderBrush="#FF3FAACA" Background="#FF3FAACA"/>
</StackPanel>
</ScrollViewer>
</Grid>
</Grid>
<!--TitlePanel contains the name of the application and page title-->
<!--ContentPanel - place additional content here-->
</Grid>
I had the same issue. but at last i solved it, i just used the Height property to do this. Please do the following steps
First create a ScrollViewer
Indide the ScrollViewer create a container(eg: Grid/StackPanel/Border etc...) and put every controlls inside it.
Set fixed Height for ScrollViewer and the Container (Note: Height of container should be greater than ScrollViewer's Height)
See the below Code
<ScrollViewer Height="500">
<Grid Name="Container" Height="700">
<TextBox/>
<TextBox/>
<TextBox/>
</Grid>
</ScrollViewer>
Now you can scroll the container Grid Even the KeyBoard shown or even focus on a TextBox.
You have to set the height of your ScrollViewer. It should be smaller than the StackPanel to achieve the scroll effect you desire. It should also be smaller than the screen size if you wish to see it's entire contents.
This is my XAML code in my project, in this first i display MainListBox then display ChatListBox depending on user selection. When user select to chat then i got run time Xaml parseing exception.
this is my whole Xaml code...
<phone:PhoneApplicationPage
x:Class="DocomoMessenger.View.Buddies"
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" d:DesignHeight="768" d:DesignWidth="480"
shell:SystemTray.IsVisible="True" Loaded="PhoneApplicationPage_Loaded">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="126"/>
<RowDefinition Height="580*"/>
<RowDefinition Height="75"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="2,2,0,2">
<ProgressBar Height="3" Name="waitprogess" Margin="0,2,0,0" />
<TextBlock x:Name="txtload" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,5,12,0" />
<TextBlock x:Name="PageTitle" Text="page name" Margin="1,0,0,0" Style="{StaticResource PhoneTextTitle1Style}" HorizontalAlignment="Center" />
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="2,0,2,0">
<Border BorderThickness="5" BorderBrush="DarkGray" CornerRadius="10" Name="buddyborder">
<ListBox x:Name="MainListBox" >
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Height="100" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Source="{Binding IM}" Stretch="Fill" Width="50" Height="50" VerticalAlignment="Center" HorizontalAlignment="Center" ></Image>
<StackPanel Margin="1,4,0,0" Grid.Column="1" x:Name="details" Height="100">
<TextBlock Text="{Binding Name}" Style="{StaticResource PhoneTextNormalStyle}" Foreground="Brown" Padding="10"/>
<TextBlock Text="{Binding StatusMsg}" FontSize="{StaticResource PhoneFontSizeSmall}" TextWrapping="Wrap" Padding="10" />
</StackPanel>
<Image Tag="{Binding Name}" Source="{Binding IMChat}" Grid.Column="2" Stretch="Uniform" Width="40" Height="40" VerticalAlignment="Center" HorizontalAlignment="Center" Name="imgchat" MouseLeftButtonUp="imgchat_MouseLeftButtonUp"></Image>
<Line Stretch="UniformToFill" Grid.ColumnSpan="3" Stroke="DarkGray" StrokeThickness="2" Margin="0,10,0,0" X1="10" Y1="10" Y2="10" VerticalAlignment="Bottom" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Border>
<ListBox x:Name="ChatListBox" Margin="2,2,0,0" Opacity="1" Visibility="Collapsed" >
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Name="megrid" Margin="3,5,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="40*"/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding FirstCol}"/>
<ColumnDefinition Width="20"/>
<ColumnDefinition Width="{Binding LastCol}"/>
</Grid.ColumnDefinitions>
<Image Name="imgbud" Source="{Binding IM}" Grid.Column="{Binding ImgCol}" Grid.Row="1" Stretch="Uniform" Width="50" Height="50"/>
<Rectangle Grid.RowSpan="2" RadiusY="20" RadiusX="20" Grid.Column="{Binding RectCol}" Fill="{Binding Bru}" />
<TextBlock Text="{Binding Name}" Grid.Row="0" TextWrapping="Wrap" Grid.Column="{Binding RectCol}" Padding="10" />
<TextBlock Text="{Binding Time}" Grid.Row="1" Grid.Column="{Binding RectCol}" Padding="10" />
<Path Data="{Binding Obj}" Fill="{Binding Bru}" Margin="0,0,-5,0" HorizontalAlignment="{Binding HorAlig}" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
<Grid x:Name="sendmsg" Height="75" VerticalAlignment="Bottom" Grid.Row="2" Visibility="Collapsed">
<TextBox Name="txtmsg" Text="type" Padding="5" Opacity="0.8" MouseLeftButtonUp="txtmsg_MouseLeftButtonUp" Width="370" HorizontalAlignment="Left" />
<Image Name="imgsend" Width="100" Height="46" Source="/DocomoMessenger;component/Themes/send.png" HorizontalAlignment="Right" Stretch="UniformToFill" Margin="0,12,4,17" MouseLeftButtonUp="imgsend_MouseLeftButtonUp"/>
</Grid>
</Grid>
<!--Sample code showing usage of ApplicationBar-->
<!--<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="MenuItem 1"/>
<shell:ApplicationBarMenuItem Text="MenuItem 2"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>-->
when I run this code i got following XamlParsinException error.
Anyone help me.
Thanks in Advance
Pavan.
I can't pin it down, it is a nearly generic message that doesn't say much.
Here is what I would do:
Comment out all content so you are left with <PhoneApplicationPage ...>
Comment out all C# code that depends on the XAML you just commented out
Make sure the application compiles.
Now slowly, step by step, add xaml elements back in. Until you find the offending line.
If 4. is too hard you could reverse this trick; comment out part by part.
whats in your PhoneApplicationPage_Loaded method?
apart from a missing end tag
</phone:PhoneApplicationPage>
in your snippet above I was able to build and run this in WP7 7.1. I did have to omit your Loaded and MouseLeftButtonUp refers though as I don't have your full code.