Related
I am trying to populate a combo-box with the contents from a table
(`InspectionTypes`) from a LINQ query without success for weeks.
When I insert a breakpoint, I can see that the data is there and the count
is correct, but nothing shows up in the drop-down list. I have a desktop
application with WPF and EF6. I am currently only working with
inspectionType10ComboBox but, there are nine other comboboxes that will
function exactly the same and use the exact same data. I am attempting to
build a quote based on which inspection(s) have been requested.
It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.
**My code behind is as follows:**
using System;
using System.Collections.ObjectModel;
using System.Data;
using System.Data.Entity;
using System.Data.SQLite.Linq;
using System.Linq;
using System.Linq.Expressions;
using System.Data.SqlClient;
using System.Data.Common;
using System.Globalization;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Navigation;
namespace WpfApp1
{
/// <summary>
/// Interaction logic for EstimatesScreen.xaml
/// </summary>
public partial class EstimatesScreen : Window
{
MIDatabase01Entities1 context = new MIDatabase01Entities1();
CollectionViewSource estimatesViewSource;
public EstimatesScreen()
{
InitializeComponent();
estimatesViewSource = ((CollectionViewSource)
(FindResource("estimatesViewSource")));
DataContext = this;
FillComboBoxes();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
System.Windows.Data.CollectionViewSource estimatesViewSource =
((System.Windows.Data.CollectionViewSource)
(this.FindResource("estimatesViewSource")));
context.Estimates.Load();
estimatesViewSource.Source = context.Estimates.Local;
}
private void FillComboBoxes()
{
var result = context.InspectionTypes.Select(p => new
{
ID = p.InspectionTypesID,
Name = p.InspectionTypeName
}).ToList();
inspectionType10ComboBox.ItemsSource = result;
inspectionType10ComboBox.SelectedValuePath = "ID";
inspectionType10ComboBox.DisplayMemberPath = "Name";
}
}
}
**My XAML is as follows (edited to reduce size. Removed "Newgrid which is
a duplacate if ExistingGrid with "New" prefix for all fields.):**
<Window x:Class="WpfApp1.EstimatesScreen"
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"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="Monroe Inspections LLC" Height="600" Width="1000"
Loaded="Window_Loaded">
<Window.Resources>
<CollectionViewSource x:Key="estimatesViewSource" d:DesignSource="
{d:DesignInstance {x:Type local:Estimate}, CreateList=True}"/>
<CollectionViewSource x:Key="inspectionTypesViewSource"
d:DesignSource="{d:DesignInstance {x:Type local:InspectionType},
CreateList=True}"/>
<RoutedUICommand x:Key="FirstCommand" Text="First"/>
<RoutedUICommand x:Key="LastCommand" Text="Last"/>
<RoutedUICommand x:Key="NextCommand" Text="Next"/>
<RoutedUICommand x:Key="DeleteCommand" Text="Delete"/>
<RoutedUICommand x:Key="UpdateCommand" Text="Update"/>
<RoutedUICommand x:Key="AddCommand" Text="Add"/>
<RoutedUICommand x:Key="CancelCommand" Text="Cancel"/>
<RoutedUICommand x:Key="PreviousCommand" Text="Previous"/>
<Style x:Key="NavButton" TargetType="{x:Type Button}" BasedOn="
{x:Null}">
<Setter Property="FontSize" Value="24"/>
<Setter Property="FontFamily" Value="Segoe UI Symbol"/>
<Setter Property="Margin" Value="2,2,2,0"/>
<Setter Property="Width" Value="40"/>
<Setter Property="Height" Value="auto"/>
</Style>
</Window.Resources>
<Window.CommandBindings>
<CommandBinding Command="{StaticResource FirstCommand}"
Executed="FirstCommandHandler"/>
<CommandBinding Command="{StaticResource LastCommand}"
Executed="LastCommandHandler"/>
<CommandBinding Command="{StaticResource NextCommand}"
Executed="NextCommandHandler"/>
<CommandBinding Command="{StaticResource PreviousCommand}"
Executed="PreviousCommandHandler"/>
<CommandBinding Command="{StaticResource DeleteCommand}"
Executed="DeleteCommandHandler"/>
<CommandBinding Command="{StaticResource UpdateCommand}"
Executed="UpdateCommandHandler"/>
<CommandBinding Command="{StaticResource AddCommand}"
Executed="AddCommandHandler"/>
<CommandBinding Command="{StaticResource CancelCommand}"
Executed="CancelCommandHandler"/>
</Window.CommandBindings>
<Grid Margin="0,0,0,0">
<Label Content="QUOTES" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="224" Height="51" FontWeight="Bold"
FontSize="36" Margin="173,9,0,0"/>
<Button Content="Return" HorizontalAlignment="Left" Margin="10,66,0,0"
VerticalAlignment="Top" Height="41" Width="136" Click="Return_Click"
FontWeight="Bold" FontFamily="Arial"/>
<Grid x:Name="ComboboxGrid" DataContext="{StaticResource
estimatesViewSource}" HorizontalAlignment="Left" Margin="165,62,0,0"
VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Label Content="Existing Quote Customer:" Grid.Column="0"
HorizontalAlignment="Left" Margin="3" Grid.Row="0"
VerticalAlignment="Center"/>
<ComboBox x:Name="customerComboBox" Grid.Column="1"
DisplayMemberPath="Customer" HorizontalAlignment="Left" Height="Auto"
ItemsSource="{Binding}" Margin="3" Grid.Row="0" VerticalAlignment="Center"
Width="200">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
</Grid>
<Grid x:Name="ExistingGrid" DataContext="{StaticResource
estimatesViewSource}" HorizontalAlignment="Left" Margin="176,112,0,0"
VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="115"/>
<ColumnDefinition Width="230"/>
<ColumnDefinition Width="210"/>
<ColumnDefinition Width="82"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Label Content="Customer:" Grid.Column="0"
HorizontalAlignment="Left" Margin="3" Grid.Row="1"
VerticalAlignment="Center"/>
<TextBox x:Name="customerTextBox" Grid.Column="1"
HorizontalAlignment="Left" Height="24" Margin="3" Grid.Row="1" Text="
{Binding Customer, Mode=TwoWay, NotifyOnValidationError=true,
ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="200"/>
<Label Content="Discount Price:" Grid.Column="2"
HorizontalAlignment="Right" Margin="3" Grid.Row="11"
VerticalAlignment="Center"/>
<TextBox x:Name="discountPriceTextBox" Grid.Column="3"
HorizontalAlignment="Left" Height="24" Margin="3" Grid.Row="11" Text="
{Binding DiscountPrice, Mode=TwoWay, NotifyOnValidationError=true,
ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="70"/>
<Label Content="Expiration Date:" Grid.Column="0"
HorizontalAlignment="Left" Margin="3" Grid.Row="11"
VerticalAlignment="Center"/>
<DatePicker x:Name="estExpirationDateDatePicker" Grid.Column="1"
HorizontalAlignment="Left" Margin="3" Grid.Row="11" SelectedDate="{Binding
EstExpirationDate, Mode=TwoWay, NotifyOnValidationError=true,
ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="125"/>
<Label Content="Quote Accepted:" Grid.Column="0"
HorizontalAlignment="Left" Margin="3" Grid.Row="12"
VerticalAlignment="Center"/>
<CheckBox x:Name="estimateAcceptedCheckBox" Content=""
Grid.Column="1" HorizontalAlignment="Left" IsChecked="{Binding
EstimateAccepted, Mode=TwoWay, NotifyOnValidationError=true,
ValidatesOnExceptions=true}" Margin="3" Grid.Row="12"
VerticalAlignment="Center"/>
<Label Content="Quote Date:" Grid.Column="0"
HorizontalAlignment="Left" Margin="3" Grid.Row="10"
VerticalAlignment="Center"/>
<DatePicker x:Name="estimateDateDatePicker" Grid.Column="1"
HorizontalAlignment="Left" Margin="3" Grid.Row="10" SelectedDate="{Binding
EstimateDate, Mode=TwoWay, NotifyOnValidationError=true,
ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="125"/>
<Label Content="Estimated Price Total:" Grid.Column="2"
HorizontalAlignment="Right" Margin="3" Grid.Row="12"
VerticalAlignment="Center"/>
<TextBox x:Name="estimatedPriceTotalTextBox" Grid.Column="3"
HorizontalAlignment="Left" Height="24" Margin="3" Grid.Row="12" Text="
{Binding EstimatedPriceTotal, Mode=TwoWay, NotifyOnValidationError=true,
ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="70"/>
<Label Content="Quote ID:" Grid.Column="0"
HorizontalAlignment="Left" Margin="3" Grid.Row="0"
VerticalAlignment="Center"/>
<TextBox x:Name="estimatesIDTextBox" Grid.Column="1"
HorizontalAlignment="Left" Height="24" Margin="3" Grid.Row="0" Text="
{Binding EstimatesID, Mode=TwoWay, NotifyOnValidationError=true,
ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="70"/>
<Label Content="Square Footage:" Grid.Column="0"
HorizontalAlignment="Left" Margin="3" Grid.Row="5"
VerticalAlignment="Center"/>
<TextBox x:Name="squareFootageTextBox" Grid.Column="1"
HorizontalAlignment="Left" Height="24" Margin="3" Grid.Row="5" Text="
{Binding SquareFootage, Mode=TwoWay, NotifyOnValidationError=true,
ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="70"/>
<TextBox x:Name="inspectionCost1TextBox" Grid.Column="3"
HorizontalAlignment="Left" Height="24" Margin="3" Grid.Row="1" Text="
{Binding InspectionCost1, Mode=TwoWay, NotifyOnValidationError=true,
ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="70"/>
<TextBox x:Name="inspectionCost10TextBox" Grid.Column="3"
HorizontalAlignment="Left" Height="23" Margin="3" Grid.Row="10" Text="
{Binding InspectionCost10, Mode=TwoWay, NotifyOnValidationError=true,
ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="70"/>
<TextBox x:Name="inspectionCost2TextBox" Grid.Column="3"
HorizontalAlignment="Left" Height="24" Margin="3" Grid.Row="2" Text="
{Binding InspectionCost2, Mode=TwoWay, NotifyOnValidationError=true,
ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="70"/>
<TextBox x:Name="inspectionCost3TextBox" Grid.Column="3"
HorizontalAlignment="Left" Height="24" Margin="3" Grid.Row="3" Text="
{Binding InspectionCost3, Mode=TwoWay, NotifyOnValidationError=true,
ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="70"/>
<TextBox x:Name="inspectionCost4TextBox" Grid.Column="3"
HorizontalAlignment="Left" Height="23" Margin="3" Grid.Row="4" Text="
{Binding InspectionCost4, Mode=TwoWay, NotifyOnValidationError=true,
ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="70"/>
<TextBox x:Name="inspectionCost5TextBox" Grid.Column="3"
HorizontalAlignment="Left" Height="22" Margin="3" Grid.Row="5" Text="
{Binding InspectionCost5, Mode=TwoWay, NotifyOnValidationError=true,
ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="70"/>
<TextBox x:Name="inspectionCost6TextBox" Grid.Column="3"
HorizontalAlignment="Left" Height="22" Margin="3" Grid.Row="6" Text="
{Binding InspectionCost6, Mode=TwoWay, NotifyOnValidationError=true,
ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="70"/>
<TextBox x:Name="inspectionCost7TextBox" Grid.Column="3"
HorizontalAlignment="Left" Height="22" Margin="3" Grid.Row="7" Text="
{Binding InspectionCost7, Mode=TwoWay, NotifyOnValidationError=true,
ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="70"/>
<TextBox x:Name="inspectionCost8TextBox" Grid.Column="3"
HorizontalAlignment="Left" Height="23" Margin="3" Grid.Row="8" Text="
{Binding InspectionCost8, Mode=TwoWay, NotifyOnValidationError=true,
ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="70"/>
<TextBox x:Name="inspectionCost9TextBox" Grid.Column="3"
HorizontalAlignment="Left" Height="23" Margin="3" Grid.Row="9" Text="
{Binding InspectionCost9, Mode=TwoWay, NotifyOnValidationError=true,
ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="70"/>
<ComboBox x:Name="inspectionType1ComboBox"
Grid.Column="2" Grid.Row="1"
Height="24" Width="200" Margin="3"
HorizontalAlignment="Left" VerticalAlignment="Center"
DataContext="inspectionTypesViewSource"
SelectedValuePath="InspectionTypeName"
SelectedValue="InspectionTypeName"
DisplayMemberPath="InspectionTypeName"
ItemsSource="{Binding result}" >
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
This is the ComboBox I am currently working on. There are nine others that will have to work exactly the same, with the dame data.
<ComboBox x:Name="inspectionType10ComboBox"
Grid.Column="2" Grid.Row="10"
Height="24" Width="200" Margin="3"
HorizontalAlignment="Left" VerticalAlignment="Center">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
<ComboBox x:Name="inspectionType2ComboBox" Grid.Column="2"
DisplayMemberPath="InspectionType2" HorizontalAlignment="Left"
Height="Auto" ItemsSource="{Binding}" Margin="3" Grid.Row="2"
VerticalAlignment="Center" Width="200">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
<ComboBox x:Name="inspectionType3ComboBox" Grid.Column="2"
DisplayMemberPath="InspectionType3" HorizontalAlignment="Left"
Height="Auto" ItemsSource="{Binding}" Margin="3" Grid.Row="3"
VerticalAlignment="Center" Width="200">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
<ComboBox x:Name="inspectionType4ComboBox" Grid.Column="2"
DisplayMemberPath="InspectionType4" HorizontalAlignment="Left"
Height="Auto" ItemsSource="{Binding}" Margin="3" Grid.Row="4"
VerticalAlignment="Center" Width="200">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
<ComboBox x:Name="inspectionType5ComboBox" Grid.Column="2"
DisplayMemberPath="InspectionType5" HorizontalAlignment="Left"
Height="Auto" ItemsSource="{Binding}" Margin="3" Grid.Row="5"
VerticalAlignment="Center" Width="200">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
<ComboBox x:Name="inspectionType6ComboBox" Grid.Column="2"
DisplayMemberPath="InspectionType6" HorizontalAlignment="Left"
Height="Auto" ItemsSource="{Binding}" Margin="3" Grid.Row="6"
VerticalAlignment="Center" Width="200">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
<ComboBox x:Name="inspectionType7ComboBox" Grid.Column="2"
DisplayMemberPath="InspectionType7" HorizontalAlignment="Left"
Height="Auto" ItemsSource="{Binding}" Margin="3" Grid.Row="7"
VerticalAlignment="Center" Width="200">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
<ComboBox x:Name="inspectionType8ComboBox" Grid.Column="2"
DisplayMemberPath="InspectionType8" HorizontalAlignment="Left"
Height="Auto" ItemsSource="{Binding}" Margin="3" Grid.Row="8"
VerticalAlignment="Center" Width="200">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
<ComboBox x:Name="inspectionType9ComboBox" Grid.Column="2"
DisplayMemberPath="InspectionType9" HorizontalAlignment="Left"
Height="Auto" ItemsSource="{Binding}" Margin="3" Grid.Row="9"
VerticalAlignment="Center" Width="200">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
<Label Content="Address:" Grid.Column="0"
HorizontalAlignment="Left" Margin="3" Grid.Row="4"
VerticalAlignment="Center"/>
<TextBox x:Name="addressTextBox" Grid.Column="1"
HorizontalAlignment="Left" Height="24" Margin="3" Grid.Row="4" Text="
{Binding Address, Mode=TwoWay, NotifyOnValidationError=true,
ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="200"/>
<Label Content="Inspection Type" Grid.Column="2"
HorizontalAlignment="Left" Margin="3" VerticalAlignment="Top" Width="97"/>
<Label Content="Cost" Grid.Column="3" HorizontalAlignment="Left"
Margin="3" VerticalAlignment="Top" Width="47"/>
<Label Content="Email:" Grid.Column="0" HorizontalAlignment="Left"
Margin="3" Grid.Row="2" VerticalAlignment="Center"/>
<TextBox x:Name="customerEmailTextBox" HorizontalAlignment="Left"
Height="23" Margin="3" Grid.Row="2" Text="{Binding CustomerEmail,
Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"
VerticalAlignment="Center" Width="215" Grid.Column="1"/>
<Label Content="Crawl Space:" Grid.Column="0"
HorizontalAlignment="Left" Margin="3" Grid.Row="6"
VerticalAlignment="Center"/>
<CheckBox x:Name="crawalSpaceCheckBox1" Content=""
HorizontalAlignment="Left" IsChecked="{Binding CrawalSpace, Mode=TwoWay,
NotifyOnValidationError=true, ValidatesOnExceptions=true}" Margin="3"
Grid.Row="6" VerticalAlignment="Center" Grid.Column="1"/>
<TextBox x:Name="additionalDiscountTextBox" Grid.Column="1"
HorizontalAlignment="Left" Height="23" Margin="3" Grid.Row="8" Text="
{Binding AdditionalDiscount, Mode=TwoWay, NotifyOnValidationError=true,
ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="70"/>
<Label Content="Extra Discount:" Grid.Column="0"
HorizontalAlignment="Left" Margin="3" Grid.Row="8"
VerticalAlignment="Center"/>
</Grid>
`NewGrid (removed for length constraints) goes here.`
<StackPanel Orientation="Horizontal" Height="35"
VerticalAlignment="Bottom" Background="Gainsboro" DataContext="
{StaticResource estimatesViewSource}" Margin="0,0,0,0">
<Button Name="btnFirst" Content="|◄" Command="{StaticResource
FirstCommand}" Style="{StaticResource NavButton}"/>
<Button Name="btnPrev" Content="◄" Command="{StaticResource
PreviousCommand}" Style="{StaticResource NavButton}"/>
<Button Name="btnNext" Content="►" Command="{StaticResource
NextCommand}" Style="{StaticResource NavButton}"/>
<Button Name="btnLast" Content="►|" Command="{StaticResource
LastCommand}" Style="{StaticResource NavButton}"/>
<Button Name="btnDelete" Content="Delete" Command="{StaticResource
DeleteCommand}" FontSize="11" Width="80" Style="{StaticResource
NavButton}"/>
<Button Name="btnAdd" Content="Add New" Command="{StaticResource
AddCommand}" FontSize="11" Width="80" Style="{StaticResource NavButton}"/>
<Button Name="btnUpdate" Content="Save" Command="{StaticResource
UpdateCommand}" FontSize="11" Width="80" Style="{StaticResource
NavButton}"/>
<Button Name="btnCancel" Content="Cancel" Command="{StaticResource
CancelCommand}" FontSize="11" Width="80" Style="{StaticResource
NavButton}"/>
</StackPanel>
</Grid>
</Window>`
`I have been looking at hundreds of samples and I am lost. The data for
the ComboBox is in my InspectionTypes table.
`
I'm trying to convert a WP8 projet to Universal Apps. I'experiecing a strange error regarding LocalizedStrings.
I use Multilingual App Toolkit to manage translations. I've updated to the latest version (4.0) which says it supports Universal apps.
The thing is it gives me this error in App.xaml: The name "LocalizedStrings" does not exist in the namespace "using:StayfilmUniversalApp".
And it is complaining on the MainPage.xaml too but not in other pages...
In MainPage.xaml it says that The type LocalizedStrings was not found. underlined in color blue the whole DataTemplate block that has a component which uses LocalizedStrings, for eg.:
<DataTemplate x:Key="TIT_WhatsNew">
<Grid Width="250" Height="52" Margin="0" HorizontalAlignment="Left">
<Rectangle Fill="White" HorizontalAlignment="Left" Height="3" Margin="0" VerticalAlignment="Top" Width="250" />
<TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" Text="{Binding LocalizedResources.WHATSNEW, Mode=OneWay, Source={StaticResource LocalizedStrings}}" VerticalAlignment="Center" FontSize="21.333" FontStretch="ExtraCondensed" FontFamily="/Assets/Fonts/Frontage-regular.otf#Frontage Regular" />
<Rectangle Fill="White" HorizontalAlignment="Left" Height="3" Margin="0" VerticalAlignment="Bottom" Width="250" />
</Grid>
</DataTemplate>
here is my App.xaml:
<Application
x:Class="StayfilmUniversalApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:StayfilmUniversalApp"
RequestedTheme="Light">
<Application.Resources>
<ResourceDictionary>
<!--<local:LocalizedStrings x:Key="LocalizedStrings"/>-->
<local:LocalizedStrings xmlns:local="using:StayfilmUniversalApp" x:Key="LocalizedStrings" />
<Color x:Key="PhoneDisabledColor">#66FFFFFF</Color>
<SolidColorBrush x:Key="PhoneDisabledBrush" Color="{StaticResource PhoneDisabledColor}" />
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles\PhoneStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- Other resources if you have -->
</ResourceDictionary>
</Application.Resources>
and My LocalizedStrings.cs:
using StayfilmUniversalApp.Resources;
namespace StayfilmUniversalApp
{
/// <summary>
/// Provides access to string resources.
/// </summary>
public class LocalizedStrings
{
private static AppResources _localizedResources = new AppResources();
public AppResources LocalizedResources { get { return _localizedResources; } }
}
}
The problem has nothing to do with LocalizedStrings.
I gave up trying to fix the page and decided to recreate it from scratch. Doing so, I found out there may be a VS bug behind and is showing different error. because when I added a DataTemplate (this one below) to a HubSection it gave me this error on the entire DataTemplate block:
Cannot add instance of type 'Windows.UI.Xaml.Setter' to a collection of type 'Windows.UI.Xaml.SetterBaseCollection'.
<DataTemplate x:Key="YOTWDataTemplate">
<ScrollViewer HorizontalAlignment="Left" VerticalAlignment="Top" BorderThickness="0" Height="548">
<StackPanel x:Name="stackYOTW" Margin="0,0,0,100" HorizontalAlignment="Center" VerticalAlignment="Top" Width="420">
<TextBlock TextWrapping="Wrap" Foreground="White" FontFamily="Portable User Interface" Margin="12,0,0,0">
<Run Text="{Binding LocalizedResources.EveryWeek, Mode=OneWay, Source={StaticResource LocalizedStrings}}"/>
<Run FontWeight="Bold" Text="YES!"/>
<LineBreak/>
<Run Text="{Binding LocalizedResources.ChoosenByStayfilm, Mode=OneWay, Source={StaticResource LocalizedStrings}}"/>
<LineBreak/>
<Run Text="{Binding LocalizedResources.ForYouToWatch, Mode=OneWay, Source={StaticResource LocalizedStrings}}"/>
</TextBlock>
<ListBox x:Name="listYOTW" ItemsSource="{Binding listYesMovie}" Foreground="White" Background="{x:Null}" BorderBrush="{x:Null}" ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Margin="12,20,0,0" Background="White" Width="420">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="64"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="64*"/>
<RowDefinition Height="119*"/>
<RowDefinition Height="50*"/>
</Grid.RowDefinitions>
<Image Margin="12" Source="{Binding user.photo}" VerticalAlignment="Center" Width="40" Height="40" HorizontalAlignment="Center" Stretch="Fill"/>
<TextBlock x:Name="NAME" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Center" FontFamily="Segoe WP Semibold" Margin="0" Grid.Column="1" Foreground="#FFAF252B" Text="{Binding user.fullName}" FontSize="18.667"/>
<TextBlock x:Name="TIME" HorizontalAlignment="Right" TextWrapping="Wrap" VerticalAlignment="Center" FontFamily="Segoe WP Light" Margin="0,0,14,0" Grid.Column="1" Foreground="#FF787878" Text="{Binding prettyPublicated}" FontSize="17.333" TextAlignment="Right"/>
<Image Grid.ColumnSpan="2" Margin="0,0,0,59" Grid.RowSpan="2" Source="{Binding thumbnailUrl}" Stretch="UniformToFill" Grid.Row="1"/>
<Grid x:Name="TituloFILM" Grid.ColumnSpan="2" Height="50" VerticalAlignment="Top" Grid.Row="1" Background="#CCAF252B">
<TextBlock x:Name="TITLE" HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding title}" VerticalAlignment="Center" Foreground="White" FontFamily="Segoe WP Light" FontSize="24" Margin="14,0,0,0"/>
</Grid>
<Grid x:Name="GridYES" Grid.ColumnSpan="2" HorizontalAlignment="Left" Grid.RowSpan="2" VerticalAlignment="Bottom" Width="80" Grid.Row="2" Height="30" Margin="14">
<Canvas x:Name="iconYES" HorizontalAlignment="Right" Height="20" UseLayoutRounding="False" VerticalAlignment="Center" Width="46" Margin="0">
<Canvas x:Name="Layer_1" Height="15.391" Canvas.Left="0.409" Canvas.Top="2.304" Width="45.182">
<Path Data="F1M10.991,0L7.327,5.987 3.619,0 0,0 5.741,8.801 5.741,14.9 8.913,14.9 8.913,8.801 14.61,0z" Fill="#FF9AA7B2" Height="14.9" Canvas.Left="0" Canvas.Top="0.223" Width="14.61"/>
<Path Data="F1M0,14.901L0,0 10.544,0 10.544,2.793 3.172,2.793 3.172,5.943 10.388,5.943 10.388,8.734 3.172,8.734 3.172,12.109 10.544,12.109 10.544,14.901z" Fill="#FF9AA7B2" Height="14.901" Canvas.Left="15.552" Canvas.Top="0.223" Width="10.544"/>
<Path Data="F1M0,13.024L1.72,10.611C2.77,11.706 4.4,12.622 6.457,12.622 8.199,12.622 9.046,11.817 9.046,10.968 9.046,8.332 0.469,10.142 0.469,4.534 0.469,2.055 2.613,0 6.121,0 8.489,0 10.455,0.715 11.929,2.077L10.164,4.4C8.958,3.283 7.349,2.77 5.83,2.77 4.468,2.77 3.708,3.373 3.708,4.267 3.708,6.635 12.263,5.048 12.263,10.611 12.263,13.336 10.32,15.391 6.299,15.391 3.44,15.391 1.384,14.431 0,13.024" Fill="#FF9AA7B2" Height="15.391" Canvas.Left="27.575" Canvas.Top="0" Width="12.263"/>
<Path Data="F1M0.537,10.053L0.067,0 3.485,0 3.039,10.053z M0,13.337C0,12.354 0.805,11.528 1.787,11.528 2.77,11.528 3.598,12.354 3.598,13.337 3.598,14.297 2.77,15.124 1.787,15.124 0.805,15.124 0,14.297 0,13.337" Fill="#FF9AA7B2" Height="15.124" Canvas.Left="41.584" Canvas.Top="0.223" Width="3.598"/>
</Canvas>
</Canvas>
<TextBlock x:Name="N_YES" HorizontalAlignment="Right" TextWrapping="Wrap" VerticalAlignment="Center" FontFamily="Segoe WP Light" Margin="0,0,59,3" Foreground="#FF35424D" Text="{Binding likeCount}" FontSize="20" TextAlignment="Right"/>
</Grid>
<Grid x:Name="GridCOMENT" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Bottom" Width="70" Grid.Row="2" Height="30" Margin="14">
<Canvas x:Name="iconCOMENT" HorizontalAlignment="Right" Height="26" UseLayoutRounding="False" VerticalAlignment="Center" Width="28" Margin="0,2,0,0">
<Canvas x:Name="Layer_4" Height="22.194" Canvas.Left="2.697" Canvas.Top="1.903" Width="22.605">
<Path Data="M23.106,0.5L0.5,0.5 0.5,16.001 6.216,16.001 3.852,22.694 13.176,16.001 23.106,16.001z" Height="24.028" Canvas.Left="-0.5" Stroke="#FF9BA8B3" Canvas.Top="-0.5" Width="23.605"/>
</Canvas>
</Canvas>
<TextBlock x:Name="N_YES1" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Center" FontFamily="Segoe WP Light" Margin="0,-3,0,0" Foreground="#FF35424D" Text="{Binding commentCount}" FontSize="20" TextAlignment="Right"/>
</Grid>
<Grid x:Name="GridVIEW" Grid.ColumnSpan="2" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="70" Grid.Row="2" Height="30" Margin="14">
<Canvas x:Name="iconVIEW" HorizontalAlignment="Right" Height="26" UseLayoutRounding="False" VerticalAlignment="Center" Width="36">
<Canvas x:Name="Layer_2" Height="18" Canvas.Left="2.113" Canvas.Top="4" Width="31.145">
<Path Data="M31.723,9.5C28.609,4.125 22.809,0.5 16.151,0.5 9.492,0.5 3.692,4.125 0.578,9.5 3.692,14.875 9.492,18.5 16.151,18.5 22.809,18.5 28.609,14.875 31.723,9.5z" Height="19" Canvas.Left="-0.578" Stroke="#FF9BA8B3" Canvas.Top="-0.5" Width="32.301"/>
<Path Data="F1M9.409,4.705C9.409,7.303 7.303,9.41 4.704,9.41 2.106,9.41 0,7.303 0,4.705 0,2.107 2.106,0 4.704,0 7.303,0 9.409,2.107 9.409,4.705" Fill="#FF9BA8B3" Height="9.41" Canvas.Left="10.868" Canvas.Top="4.295" Width="9.409"/>
</Canvas>
</Canvas>
<TextBlock x:Name="N_YES2" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Center" FontFamily="Segoe WP Light" Margin="0,-3,0,0" Foreground="#FF35424D" Text="{Binding viewCount}" FontSize="20" TextAlignment="Right"/>
</Grid>
<Button Background="{x:Null}" BorderBrush="{x:Null}" Foreground="{x:Null}" Margin="0,50,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.ColumnSpan="2" Grid.Row="1" Click="Button_Click" Style="{StaticResource ButtonStyle}">
<Canvas x:Name="PLAY" HorizontalAlignment="Center" Height="102" UseLayoutRounding="False" VerticalAlignment="Center" Width="102">
<Canvas x:Name="Layer_3" Height="96" Canvas.Left="2" Canvas.Top="2" Width="96" Margin="0" Background="{StaticResource TransparentBrush}">
<Path Data="F1M0,0L29.333,16.936 0,33.871z" Fill="White" Height="33.871" Canvas.Left="38.26" Canvas.Top="30.998" Width="29.333" Stroke="#26000000"/>
<Ellipse Height="98" Stroke="#26000000" StrokeThickness="5" Width="98" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Ellipse Height="96" Stroke="White" StrokeThickness="3" Width="96" HorizontalAlignment="Center" VerticalAlignment="Center" Canvas.Left="1" Canvas.Top="1"/>
</Canvas>
</Canvas>
</Button>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TextBlock x:Name="txt_NoConnection" Foreground="White" TextWrapping="Wrap" Text="{Binding LocalizedResources.NoConnection, Mode=OneWay, Source={StaticResource LocalizedStrings}}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,48,0,0" FontFamily="Segoe WP Light" Visibility="Collapsed"/>
</StackPanel>
</ScrollViewer>
</DataTemplate>
and I say it is a VS bug because I found this: VS bug report
I made a product page but the scrollviewer does not show everything that is in that grid. I have a feeling that is has something to do with my row definitions I hope someone can help me
XAML:
<Page
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Height="729.552">
<Page.Resources>
</Page.Resources>
<Grid x:Name="LayoutRoot" d:DataContext="{d:DesignData /SampleData/RootObjectSampleData2.xaml}" HorizontalAlignment="Left" VerticalAlignment="Top">
<Grid.ChildrenTransitions>
<TransitionCollection>
<EntranceThemeTransition/>
</TransitionCollection>
</Grid.ChildrenTransitions>
<!--TODO: Content should be placed within the following grid-->
<Grid x:Name="ContentPanel" HorizontalAlignment="Left" VerticalAlignment="Top">
<Pivot x:Name="ProductHub" HorizontalAlignment="Left" VerticalAlignment="Top">
<PivotItem x:Name="ProductPivot" Header="Item" DataContext="{Binding}" HorizontalAlignment="Left" VerticalAlignment="Top" Height="680">
<ScrollViewer Width="336" Height="670" HorizontalAlignment="Left" VerticalAlignment="Top" >
<Grid x:Name="ContentGrid" Height="auto" Margin="0">
<Grid.RowDefinitions>
<RowDefinition Height="auto" MinHeight="278"/>
<RowDefinition Height="30*"/>
<RowDefinition Height="auto" MinHeight="251"/>
<RowDefinition Height="77*"/>
<RowDefinition Height="34*"/>
</Grid.RowDefinitions>
<TextBlock x:Name="TBlockTitle" HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="{Binding result.item.title}" VerticalAlignment="Top" Height="20" d:DataContext="{d:DesignData /SampleData/RootObjectSampleData.xaml}"/>
<Image x:Name="ImageProduct" HorizontalAlignment="Left" Height="160" Margin="10,49,0,0" VerticalAlignment="Top" Width="316" Stretch="Fill" Source="{Binding result.item.images.Item330}" Tapped="ImgProduct_Click" />
<TextBlock x:Name="BtnFavorite" HorizontalAlignment="Left" Margin="10,214,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" FontFamily="Segoe MDL2 Assets" FontSize="20" Height="20" Width="20" />
<TextBlock x:Name="TBlockHiddenSEO" HorizontalAlignment="Left" Margin="298,10,-6,0" TextWrapping="Wrap" Text="{Binding result.item.seo_name}" VerticalAlignment="Top" Opacity="0" Height="40" Width="44"/>
<TextBlock x:Name="textBlockCurrency" HorizontalAlignment="Left" Margin="192,218,0,0" TextWrapping="Wrap" Text="{Binding result.item.currency_symbol}" VerticalAlignment="Top" Height="20" Width="8"/>
<TextBlock x:Name="textBlockPrice" HorizontalAlignment="Left" Margin="205,218,0,0" TextWrapping="Wrap" Text="{Binding result.item.price}" VerticalAlignment="Top" Height="20" Width="28"/>
<TextBlock x:Name="textBlockLookAmmount" HorizontalAlignment="Left" Margin="10,258,0,0" TextWrapping="Wrap" Text="{Binding result.item.views}" VerticalAlignment="Top" Height="20" Width="16" d:DataContext="{d:DesignData /SampleData/RootObjectSampleData.xaml}"/>
<TextBlock x:Name="textBlockWatchedText" HorizontalAlignment="Left" Margin="31,258,0,0" TextWrapping="Wrap" Text="x bekeken sinds" VerticalAlignment="Top" Height="20" Width="105"/>
<TextBlock x:Name="textBlockDate" HorizontalAlignment="Left" Margin="141,258,0,0" TextWrapping="Wrap" Text="{Binding result.item.placed}" VerticalAlignment="Top" Height="20" Width="81" d:DataContext="{d:DesignData /SampleData/RootObjectSampleData.xaml}"/>
<StackPanel x:Name="StPanelUser" Grid.Row="1" Margin="0,10,0,20"/>
<TextBlock x:Name="textBlockDescription" HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="{Binding result.item.description}" VerticalAlignment="Top" Width="316" Grid.Row="1"/>
<TextBlock x:Name="textBlockShipping" HorizontalAlignment="Left" Margin="10,1,0,0" Grid.Row="2" TextWrapping="Wrap" Text="Shipping" VerticalAlignment="Top" Height="20" Width="59"/>
<TextBlock x:Name="textBlockState" HorizontalAlignment="Left" Margin="10,26,0,0" Grid.Row="2" TextWrapping="Wrap" Text="State" VerticalAlignment="Top" Height="20" Width="59"/>
</Grid>
</ScrollViewer>
</PivotItem>
</Pivot>
</Grid>
<ProgressRing HorizontalAlignment="Left" VerticalAlignment="Top" x:Name="ProgressRing"/>
</Grid>
Thank you
I'm pretty sure, that the parent element of your scrollviewer has a smaller height than the scrollviewer itself - the height of the scrollviewer sets the height of the control, not the heigh of the content...
As consequence, if the scrollviewer is 200px greater than the parent control - the last 200px of the scrollviewer are cut off
Remove Height="670" in the ScrollViewer. If you set the height for a ScrollViewer, then it displays the controls that fits in the given height
<ScrollViewer Width="336" HorizontalAlignment="Left" VerticalAlignment="Top" >
....
....
</ScrollViewer>
.
<Window x:Class="minimizeApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid >
<ScrollViewer Width="336" HorizontalAlignment="Left" VerticalAlignment="Top" >
<Grid x:Name="ContentGrid" Height="auto" Margin="0">
<Grid.RowDefinitions>
<RowDefinition Height="auto" MinHeight="278"/>
<RowDefinition Height="30*"/>
<RowDefinition Height="auto" MinHeight="251"/>
<RowDefinition Height="77*"/>
<RowDefinition Height="34*"/>
</Grid.RowDefinitions>
<TextBlock x:Name="TBlockTitle" HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="title" VerticalAlignment="Top" Height="20" />
<Image x:Name="ImageProduct" HorizontalAlignment="Left" Height="160" Margin="10,49,0,0" VerticalAlignment="Top" Width="316" Stretch="Fill" Source="Images/graph1.jpg" />
<TextBlock x:Name="BtnFavorite" HorizontalAlignment="Left" Margin="10,214,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" FontFamily="Segoe MDL2 Assets" FontSize="20" Height="20" Width="20" />
<TextBlock x:Name="TBlockHiddenSEO" HorizontalAlignment="Left" Margin="298,10,-6,0" TextWrapping="Wrap" Text="name" VerticalAlignment="Top" Opacity="0" Height="40" Width="44"/>
<TextBlock x:Name="textBlockCurrency" HorizontalAlignment="Left" Margin="192,218,0,0" TextWrapping="Wrap" Text="currency" VerticalAlignment="Top" Height="20" Width="8"/>
<TextBlock x:Name="textBlockPrice" HorizontalAlignment="Left" Margin="205,218,0,0" TextWrapping="Wrap" Text="price" VerticalAlignment="Top" Height="20" Width="28"/>
<TextBlock x:Name="textBlockLookAmmount" HorizontalAlignment="Left" Margin="10,258,0,0" TextWrapping="Wrap" Text="123" VerticalAlignment="Top" Height="20" Width="16" />
<TextBlock x:Name="textBlockWatchedText" HorizontalAlignment="Left" Margin="31,258,0,0" TextWrapping="Wrap" Text="x bekeken sinds" VerticalAlignment="Top" Height="20" Width="105"/>
<TextBlock x:Name="textBlockDate" HorizontalAlignment="Left" Margin="141,258,0,0" TextWrapping="Wrap" Text="placed" VerticalAlignment="Top" Height="20" Width="81" />
<StackPanel x:Name="StPanelUser" Grid.Row="1" Margin="0,10,0,20"/>
<TextBlock x:Name="textBlockDescription" HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="description" VerticalAlignment="Top" Width="316" Grid.Row="1"/>
<TextBlock x:Name="textBlockShipping" HorizontalAlignment="Left" Margin="10,1,0,0" Grid.Row="2" TextWrapping="Wrap" Text="Shipping" VerticalAlignment="Top" Height="20" Width="59"/>
<TextBlock x:Name="textBlockState" HorizontalAlignment="Left" Margin="10,26,0,0" Grid.Row="2" TextWrapping="Wrap" Text="State" VerticalAlignment="Top" Height="20" Width="59"/>
<TextBlock x:Name="textBlockpayment" HorizontalAlignment="Left" Margin="10,51,0,0" Grid.Row="2" TextWrapping="Wrap" Text="Payment" VerticalAlignment="Top" Height="20" Width="72"/>
<TextBlock x:Name="textBlockType" HorizontalAlignment="Left" Margin="10,76,0,0" Grid.Row="2" TextWrapping="Wrap" Text="Type" VerticalAlignment="Top" Height="20" Width="59"/>
<TextBlock x:Name="textBlockRole" HorizontalAlignment="Left" Margin="10,101,0,0" Grid.Row="2" TextWrapping="Wrap" Text="Role" VerticalAlignment="Top" Height="20" Width="59"/>
<TextBlock x:Name="textBlockShipping_FillIn" HorizontalAlignment="Left" Margin="141,1,0,0" Grid.Row="2" TextWrapping="Wrap" Text="123" VerticalAlignment="Top" Height="20" Width="0"/>
<TextBlock x:Name="textBlockState_FillIn" HorizontalAlignment="Left" Margin="141,26,0,0" Grid.Row="2" TextWrapping="Wrap" Text="123" VerticalAlignment="Top" Height="20" Width="0"/>
<TextBlock x:Name="textBlockpayment_FillIn" HorizontalAlignment="Left" Margin="141,51,0,0" Grid.Row="2" TextWrapping="Wrap" Text="123" VerticalAlignment="Top" Height="20" Width="0"/>
<TextBlock x:Name="textBlockType_FillIn" HorizontalAlignment="Left" Margin="141,76,0,0" Grid.Row="2" TextWrapping="Wrap" Text="123" VerticalAlignment="Top" Height="20" Width="0"/>
<TextBlock x:Name="textBlockRole_FillIn" HorizontalAlignment="Left" Margin="141,101,0,0" Grid.Row="2" TextWrapping="Wrap" Text="1323" VerticalAlignment="Top" Height="20" Width="0"/>
<TextBlock x:Name="textBlockAdvertiser" HorizontalAlignment="Left" Margin="10,149,0,0" Grid.Row="2" TextWrapping="Wrap" Text="Adverteerder" VerticalAlignment="Top" Height="20" Width="87"/>
<TextBlock x:Name="textBlockLocation" HorizontalAlignment="Left" Margin="10,174,0,0" Grid.Row="2" TextWrapping="Wrap" Text="Locatie" VerticalAlignment="Top" Height="20" Width="87"/>
<TextBlock x:Name="textBlockPhone" HorizontalAlignment="Left" Margin="10,231,0,0" Grid.Row="2" TextWrapping="Wrap" Text="Telefoon" VerticalAlignment="Top" Height="20" Width="87"/>
<TextBlock x:Name="textBlockAdvertiser_FillIn" HorizontalAlignment="Left" Margin="141,149,0,0" Grid.Row="2" TextWrapping="Wrap" Text="name" VerticalAlignment="Top" Height="20" Width="37"/>
<TextBlock x:Name="textBlockLocation_FillIn" HorizontalAlignment="Left" Margin="141,174,0,0" Grid.Row="2" TextWrapping="Wrap" Text="123" VerticalAlignment="Top" Height="20" Width="8"/>
<TextBlock x:Name="textBlockProvince_FillIn" HorizontalAlignment="Left" Margin="141,199,0,0" Grid.Row="2" TextWrapping="Wrap" Text="123" VerticalAlignment="Top" Height="20" Width="0"/>
<TextBlock x:Name="textBlockPhone_FillIn" HorizontalAlignment="Left" Margin="141,231,0,0" Grid.Row="2" TextWrapping="Wrap" Text="phone" VerticalAlignment="Top" Height="20"/>
</Grid>
</ScrollViewer>
</Grid>
</Window>
I have been up and down looking on the internet and many people seem to have this problem but its generally solved by changing the container to a grid, constraining the height etc. etc. I can't to seem to get this to work.
I have an observableCollection thats feeding into a DataTemplate. I can't for th life of me get the scrollbar working. Its there but not enabling. Thanks Scott
<TabItem Header="select a call" x:Name="TabActiveCalls" Style="{DynamicResource MyTabItem}" FontFamily="QuickType">
<Grid Margin="0.125,0.412,3.125,0" Height="471" HorizontalAlignment="Stretch">
<StackPanel Orientation="Horizontal" Width="839.14" HorizontalAlignment="Left" VerticalAlignment="Top" Height="56">
<StackPanel Orientation="Vertical" HorizontalAlignment="Left" Margin="0,0,10,0" Width="741.14">
<StackPanel Height="28" Orientation="Horizontal" Width="733.14" HorizontalAlignment="Left">
<TextBlock x:Name="txtHistoryFound" TextWrapping="Wrap" Text="*" Foreground="#FFE20A0A" Visibility="Collapsed"/>
<TextBlock TextWrapping="Wrap" Text="filter by:" Margin="5,0,10,0" Foreground="#FF585AD4" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBlock TextWrapping="Wrap" Text="call no" Margin="5,0,2,0" VerticalAlignment="Center" Foreground="#FF5E88DA"/>
<TextBox Template="{StaticResource TextBoxBaseControlTemplate}" x:Name="searchCallNo" TextChanged="searchCallNo_TextChanged" TextWrapping="Wrap" Width="67" Foreground="#FF1341B1" TextAlignment="Center" Margin="5,0,10,0" Height="22" VerticalAlignment="Center" />
<TextBlock TextWrapping="Wrap" Text="postcode" Margin="5,0,2,0" VerticalAlignment="Center" Foreground="#FF5E88DA"/>
<TextBox Template="{StaticResource TextBoxBaseControlTemplate}" x:Name="searchPostcode" TextWrapping="Wrap" Width="67" Foreground="#FF1341B1" TextAlignment="Center" Margin="5,0,10,0" Height="22" VerticalAlignment="Center"/>
<TextBlock Height="23" x:Name="txtSiteName" FontSize="16" Foreground="#FF0E7C0B" Width="409" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0" TextAlignment="Right" Text="Airedale International Ltd" />
</StackPanel>
<StackPanel Width="733.14" HorizontalAlignment="Left">
<Border Height="21" Margin="5,6,8,0" CornerRadius="3,3,0,0" BorderThickness="1" BorderBrush="#FFC0BABA">
<StackPanel Orientation="Horizontal" Background="#FFD0D5DE">
<TextBlock TextWrapping="Wrap" Text="CALL NO. / DATE DUE/ CUSTOMER" Margin="5,0,0,0" Foreground="{DynamicResource ListTitle}" FontSize="10.667" VerticalAlignment="Center"/>
<TextBlock TextWrapping="Wrap" Text="ENGINEER / ADDRESS" Margin="114,0,0,0" Foreground="{DynamicResource ListTitle}" VerticalAlignment="Center"/>
<TextBlock TextWrapping="Wrap" Text="REPORT" Margin="43,0,0,0" Foreground="{DynamicResource ListTitle}" RenderTransformOrigin="2.543,0.429" VerticalAlignment="Center"/>
<TextBlock TextWrapping="Wrap" Text="CALL" Margin="28,0,0,0" Foreground="{DynamicResource ListTitle}" RenderTransformOrigin="2.543,0.429" VerticalAlignment="Center"/>
<TextBlock TextWrapping="Wrap" Text="POSITION" Margin="43,0,0,0" Foreground="{DynamicResource ListTitle}" RenderTransformOrigin="2.543,0.429" VerticalAlignment="Center"/>
</StackPanel>
</Border>
</StackPanel>
</StackPanel>
<Image Height="56" Width="90" Source="/ComfortReportEng;component/Media/Images/comfort_group.png"/>
</StackPanel>
<ListBox ItemTemplate="{StaticResource DataTemplateReportList}" ItemsSource="{Binding Source={StaticResource cvsReportList}}"
Margin="5,56,8,0" MaxHeight="415" Height="415" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.CanContentScroll="True"/>
</Grid>
</TabItem>
many thanks for getting back. Here is my DataTempate
<DataTemplate x:Key="DataTemplateReportList">
<Border Margin="0,2,0,0" BorderThickness="1" BorderBrush="#FFA19C9C" CornerRadius="3,3,0,0" Width="810.52" Height="50" >
<Grid Background="#FF737B89" Height="48" >
<StackPanel Orientation="Vertical" HorizontalAlignment="Left" Width="274" VerticalAlignment="Top" >
<StackPanel Height="23" Orientation="Horizontal" Margin="0">
<TextBlock TextWrapping="Wrap" Text="{Binding CallNo, Mode=TwoWay}" Foreground="#FF7DF51E" Margin="5,0,0,0" FontFamily="Verdana"/>
<TextBlock TextWrapping="Wrap" Text="{Binding DateDue, Mode=TwoWay, StringFormat=d}" Foreground="White" Margin="5,0,0,0" FontFamily="Verdana"/>
</StackPanel>
<StackPanel Height="23" Orientation="Horizontal">
<TextBlock TextWrapping="Wrap" Text="{Binding CompanyName, Mode=TwoWay}" Foreground="#FFFFEA00" Margin="5,0,0,0" FontFamily="Verdana"/>
</StackPanel>
</StackPanel>
<StackPanel HorizontalAlignment="Left" Width="456" Orientation="Vertical" Height="46" Margin="274,1,0,1" VerticalAlignment="Top">
<StackPanel Height="23" Orientation="Horizontal">
<TextBlock TextWrapping="Wrap" Text="{Binding EngineerName, Mode=TwoWay}" Foreground="#FFCAE5C6" Margin="5,0,0,0" FontFamily="Verdana" Width="140"/>
<TextBlock TextWrapping="Wrap" Text="{Binding ReportStatus, Mode=TwoWay}" Foreground="#FF7DF51E" Margin="20,0,0,0" FontFamily="Verdana" Width="50"/>
<TextBlock TextWrapping="Wrap" Text="{Binding CallStatus, Mode=TwoWay}" Foreground="#FF7DF51E" Margin="20,0,0,0" FontFamily="Verdana" Width="50"/>
<TextBlock TextWrapping="Wrap" Text="{Binding Position, Mode=TwoWay}" Foreground="White" Margin="20,0,0,0" FontFamily="Verdana" Width="50"/>
</StackPanel>
<StackPanel Height="23" Orientation="Horizontal">
<TextBlock TextWrapping="Wrap" Text="{Binding Address, Mode=TwoWay}" Foreground="#FFFFEA00" Margin="5,0,0,0" FontFamily="Verdana" Width="483.12"/>
</StackPanel>
</StackPanel>
<Grid Width="56" HorizontalAlignment="Right" Margin="0,0,12.52,0" VerticalAlignment="Top">
<Image Name="imgInfo" Source="/ComfortReportEng;component/Media/Images/Info4.png" Margin="24,8,0,0" Cursor="Hand" MouseLeftButtonDown="imgInfo_MouseLeftButtonDown"/>
</Grid>
</Grid>
</Border>
</DataTemplate>
Must be a bug. I have the following only..
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ComfortReportEng.Views.EngineerReport.EngineerReport"
Title="Engineer Report" WindowStartupLocation="CenterScreen" Loaded="Window_Loaded" SizeToContent="WidthAndHeight" >
<Window.Resources>
<CollectionViewSource x:Key="cvsReportList"/>
</Window.Resources>
<Grid Margin="0.125,0.412,3.125,0" Height="471">
<ListBox Margin="23,64,3,0" Width="834.14" ItemsSource="{Binding Source={StaticResource cvsReportList}}"
x:Name="lbReportList" SelectionChanged="lbReportList_SelectionChanged" Background="#FFEEEFE4" />
</Grid>
and code is
private void LoadReportList()
{
int number = 0;
List<int> myNumbers = new List<int>();
while (number < 80)
{
myNumbers.Add(number);
number += 1;
}
_cvsReportList = (CollectionViewSource)(this.FindResource("cvsReportList"));
_cvsReportList.Source = myNumbers;
}
This was copied over from another project. Completely confused. Please don't worry. It's not a logical problem. Please take this as a close call with no solution. Cheers again Scott
Just to give this completeness. I am not sure why this happens but here is it.
if (System.Environment.MachineName == "SCOTT-PC")
{
this.txtUserName.Text = "Scott Fisher";
this.txtPassword.Password = "palace";
//LoginOK();
}
else
Keyboard.Focus(this.txtUserName);
If I clear the comments on LoginOK procedure I will get no scrollbar. With it commented and I interact with the login screen then everything is fine. Finally here is the code for the LoginOK.
if (LoginService.CheckLogin(txtUserName.Text, txtPassword.Password.ToString()))
{
Helpers.User.ThisUser = this.txtUserName.Text;
EngineerReport.EngineerReport engReport = new EngineerReport.EngineerReport()
{
Owner = Window.GetWindow(this),
WindowStartupLocation =
System.Windows.WindowStartupLocation.
CenterOwner
};
this.Hide();
engReport.ShowDialog();
}
else
{
this.txtPassword.Password = "";
this.txtPassword.Focus();
}
Can you provide you DataTemplate as I believe I have just managed to mock up what you are trying to achieve and I have scrollbars visible and working form the start.
Here is the xaml that I used for the DataTemplate for the ListBox:
<ListBox DataContext="{StaticResource MusicData}" ItemsSource="{Binding XPath=Album}">
<ListBox.ItemTemplate>
<DataTemplate>
<ListBoxItem>
<StackPanel Orientation="Horizontal" >
<TextBlock>No.</TextBlock>
<TextBlock Text="{Binding XPath=No}"></TextBlock>
<TextBlock>Title</TextBlock>
<TextBlock Text="{Binding XPath=Title}"></TextBlock>
</StackPanel>
</ListBoxItem>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Hope this helps.
I also found a piece of code I used a while back and this might help. You can try setting the ItemsPanelTemplate:
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel>
<ScrollViewer VerticalScrollBarVisibility="Visible" />
</StackPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
This will work with any items control as stated in this article:
http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.itemcontainerstyle.aspx
One final thing I can suggest is to create your own ControlTemplate for the ListBox Like so:
<ListBox.Template>
<ControlTemplate>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<ItemsPresenter />
</ScrollViewer>
</ControlTemplate>
</ListBox.Template>
It's a very stupid question :)
Which property sets vertical scroll?
Developing Windows Phone 7 app, I switched off this property, and I don't understand, how I did it :)
I use ComboBox, and when I create project, I can scroll text in ComboBox, but now I can't
You need to include all the items inside the Scrollviewer, as in pivot page, we can't make the content scroller without scroll viewer.
Here is the sample content.
<ScrollViewer HorizontalAlignment="Left" VerticalAlignment="Top" Height="647" Margin="0" Grid.Row="1">
<Grid x:Name="ContentPanel" Margin="0,0,0,24" Width="480" Height="1470" Grid.Row="1">
<Image x:Name="ImgProcess" Source="/GoogTaxi;component/images/loading2.jpg" Visibility="Collapsed" Stretch="None" Opacity="0.60" VerticalAlignment="Top" />
<TextBlock x:Name="tbkCompanyName" TextWrapping="Wrap" Text="Company Name" Margin="20,20,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtCompanyName" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,47,8,0"/>
<TextBlock x:Name="tbkAddress" TextWrapping="Wrap" Text="Address" Margin="20,120,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtAddress" AcceptsReturn="True" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,147,8,336" VerticalScrollBarVisibility="Auto" Height="131"/>
<TextBlock x:Name="tbkEmailId" TextWrapping="Wrap" Text="Email Id" Margin="20,279,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtEmailId" IsEnabled="False" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,306,8,0" d:LayoutOverrides="VerticalAlignment"/>
<TextBlock x:Name="tbkWebsite" TextWrapping="Wrap" Margin="20,379,0,0" VerticalAlignment="Top"><Run Text="Website"/><LineBreak/><Run/></TextBlock>
<TextBox x:Name="txtWebsite" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,406,8,0" d:LayoutOverrides="VerticalAlignment"/>
<TextBlock x:Name="tbkPhone" TextWrapping="Wrap" Text="Phone" Margin="20,479,0,0" VerticalAlignment="Top" d:LayoutOverrides="VerticalAlignment"/>
<TextBox x:Name="txtPhone" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,506,8,0"/>
<TextBlock x:Name="tbkCity" TextWrapping="Wrap" Margin="20,579,0,0" VerticalAlignment="Top" Text="City"/>
<TextBox x:Name="txtCity" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,606,8,0"/>
<TextBlock x:Name="tbkState" TextWrapping="Wrap" Text="State" Margin="20,676,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtState" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,704,8,0"/>
<TextBlock x:Name="tblCountry" TextWrapping="Wrap" Text="Country" Margin="20,780,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtCountry" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,806,8,0"/>
<TextBlock x:Name="tbkCompany_logo" Visibility="Collapsed" TextWrapping="Wrap" Text="Contact Person" Margin="20,0,0,42.602" VerticalAlignment="Top" d:IsHidden="True"/>
<TextBox x:Name="txtCompany_logo" Visibility="Collapsed" TextWrapping="Wrap" Margin="8,0,8,-29.305" VerticalAlignment="Top" d:IsHidden="True"/>
<TextBlock x:Name="tbkContactPerson" TextWrapping="Wrap" Text="Contact Person" Margin="20,879,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtContactPerson" TextWrapping="Wrap" Margin="8,908,8,0" VerticalAlignment="Top"/>
<TextBlock x:Name="tbkContactPhone" TextWrapping="Wrap" Text="Contact Person Phone" Margin="20,982,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtContactPhone" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,1005,8,0"/>
<TextBlock x:Name="tbkContactEmail" TextWrapping="Wrap" Text="Contact person Email ID" Margin="20,1079,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtContactEmail" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,1106,8,0"/>
<TextBlock x:Name="tbkMerchantId" TextWrapping="Wrap" Text="Google Merchant Id" Margin="20,1180,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtMerchantId" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,1209,8,0" IsEnabled="False" />
<TextBlock x:Name="tbkMerchantKey" TextWrapping="Wrap" Text="Google Merchant Key" Margin="20,1282,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtMerchantKey" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,1310,8,0" IsEnabled="False" />
<Button x:Name="btnsave" Content="Save" Margin="33,1390,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Click="btnsave_Click" />
<Button x:Name="btnCancel" Content="Cancel" Margin="0,1390,33,0" VerticalAlignment="Top" HorizontalAlignment="Right" d:LayoutOverrides="HorizontalAlignment" Click="btnCancel_Click" />
</Grid>
</ScrollViewer>
There is no scroll functionality inside PivotItem. You should use ScrollViewer control to get it by your own.
In a pivot control, if the content is overflowing the vertical page then there should be default "vertical" scrolling available to you.
I had a similar control with "list box" bounded to property. Having the list box should automatically allow you to scroll.
Don't add a scrollviewer over the stack panel as it would make the scrolling enabled for each list item which you don't want.
<controls:PivotItem Header="all authors" Foreground="#FF0C388A">
<Grid>
<ListBox Margin="0,0,-12,0" ItemsSource="{Binding AllAuthorsList}" Foreground="#FF0C388A">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17" Width="432" Height="Auto">
<TextBlock Tap="TextBlockAuthor_Tap" Text="{Binding}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" Foreground="#FF0C388A"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</controls:PivotItem>