I am writing a Windows Phone 8.1 App.
It has GridView, First row must show 2 items, 2nd and 3rd row must show 3 items each and rest rows must show 4 items. I am trying to use VariableSizedGridView:
Click Here to View Image
but my items are being shown in 1 column like a long list.
Click to view ScreenShot
XAML:
<UserControls:VariableSizedGridView x:Name="ModelRingsGridViewVariable" HorizontalAlignment="Stretch">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VariableSizedWrapGrid ItemHeight="180"
ItemWidth="20" Orientation="Horizontal"/>
<!--ItemWidth="{Binding ElementName=modelPage, Path=WidthCalculator}"-->
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.ItemTemplate>
<DataTemplate>
<Grid Background="White" Margin="2">
<StackPanel Orientation="Vertical">
<Image Height="100" VerticalAlignment="Top" Source="{Binding ImageLocation}" Stretch="Fill"></Image>
<Grid Background="{StaticResource LightGreenBlueColor}" VerticalAlignment="Bottom"
HorizontalAlignment="Stretch">
<TextBlock Margin="0,8,0,8" VerticalAlignment="Center"
HorizontalAlignment="Center" FontSize="18"
Text="{Binding ImageName}" Foreground="White"></TextBlock>
</Grid>
</StackPanel>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</UserControls:VariableSizedGridView>
C#:
private void GenerateGridViewData()
{
ModelRingsGridViewVariable.Width = Window.Current.Bounds.Width;
ObservableCollection<ModelClass> ModelRingsGridViewData = new ObservableCollection<ModelClass>();
int j = 1;
Uri location = new Uri("ms-appx:///Images/TestImages/TestImageRing.png", UriKind.RelativeOrAbsolute);
for (int i=0; i<20;i++)
{
if(i==0 || i== 1)
{
ModelRingsGridViewData.Add(new ModelClass { ImageName = "RING " + j.ToString(), ImageLocation = location, ColSpan=6 });
}
else if(i== 2 || i==3 || i==4)
{
ModelRingsGridViewData.Add(new ModelClass { ImageName = "RING " + j.ToString(), ImageLocation = location, ColSpan=4 });
}
else
{
ModelRingsGridViewData.Add(new ModelClass { ImageName = "RING " + j.ToString(), ImageLocation = location,ColSpan=3 });
}
j++;
}
ModelRingsGridViewVariable.ItemsSource = ModelRingsGridViewData;
}
Model:
public class ModelClass
{
public Uri ImageLocation { get; set; }
public String ImageName { get; set; }
public int ColSpan { get; set; }
}
VariableSizedGridView.cs:
public class VariableSizedGridView : GridView
{
protected override void PrepareContainerForItemOverride(DependencyObject element,
object item)
{
try
{
dynamic localItem = item;
// element.SetValue(VariableSizedWrapGrid.RowSpanProperty, localItem.RowSpan);
element.SetValue(VariableSizedWrapGrid.ColumnSpanProperty, localItem.ColSpan);
}
catch
{
// element.SetValue(VariableSizedWrapGrid.RowSpanProperty, 1);
element.SetValue(VariableSizedWrapGrid.ColumnSpanProperty, 1);
}
base.PrepareContainerForItemOverride(element, item);
}
}
Related
View.Xaml
<Grid>
<ListView ItemsSource = "{Binding Path = dcCategory}" SelectedValuePath = "Key" SelectedValue = "{Binding Path = Category, Mode = TwoWay}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<StackPanel Orientation="Horizontal" >
<Button Content="Add Value" Command="{Binding Path=DataContext.AddValue, RelativeSource= {RelativeSource FindAncestor, AncestorType={x:Type ListView}}}"/>
<TextBlock Text="{Binding Path=Key.Name}"/>
</StackPanel>
<ListBox ItemsSource="{Binding Path=Value}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
</Grid>
My goal is to click Add Value and send selected item (Category type). Its right now it's working but not as I acepted.
Insted of clicking only button, I have to click first blue area and then code 'catch' the 'Category' with data. Otherwise Category is null.
example
ViewModel
private Category _Category;
public Category Category
{
get
{
return _Category;
}
set
{
if (_Category != value)
{
_Category = value;
OnPropertyChanged(() => Category);
}
}
}
public ICommand AddValue
{
get
{
if (_AddValue == null)
{
_AddValue = new BaseCommand(() => Messenger.Default.Send(CategoryValueCode.AddValue + "," + Category.CategoryId));
}
return _AddValue;
}
}
That's logic, because your button's command will be executed before ListView.SelectedValue is set. You can change it, if you handle PreviewMouseDown for the Button. I also found it better to set ListView.SelectionMode to Single.
<ListView ItemsSource = "{Binding Path = dcCategory}" SelectedValuePath = "Key" SelectedValue = "{Binding Path = Category, Mode = TwoWay}" SelectionMode="Single">
<Button Content="Add Value" Command="{Binding Path=DataContext.AddValue, RelativeSource= {RelativeSource FindAncestor, AncestorType={x:Type ListView}}}" PreviewMouseDown="PreviewMouseDown"/>
private void PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
ListViewItem lvi = null;
var visParent = VisualTreeHelper.GetParent(sender as FrameworkElement);
while (lvi == null && visParent != null)
{
lvi = visParent as ListViewItem;
visParent = VisualTreeHelper.GetParent(visParent);
}
if (lvi == null) { return; }
lvi.IsSelected = true;
}
I didn't check Rekshino solution
Thank you for the tips, in the meantime during fighting with the problem I made so many changes that completely change viewmodel / view.
I achieved my goal in that way:
View:
<Grid>
<ItemsControl ItemsSource = "{Binding listCategoryAddValue}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<StackPanel Orientation="Horizontal">
<Button Content="Add Value" Command="{Binding Path=AddValue}"/>
<TextBlock Text="{Binding Category.Name}"/>
</StackPanel>
<ListBox ItemsSource="{Binding ValueList}" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal">
</StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</Grid>
ViewModel:
public class CategoriesViewModel : WszystkieViewModel<CategoryAddValue>
{
#region Fields & Properties
private ObservableCollection<CategoryAddValue> _listCategoryAddValue;
public ObservableCollection<CategoryAddValue> listCategoryAddValue
{
get
{
if (_listCategoryAddValue == null) { Load(); }
return _listCategoryAddValue;
}
set
{
if (_listCategoryAddValue != value)
{
_listCategoryAddValue = value;
OnPropertyChanged(() => listCategoryAddValue);
}
}
}
#endregion Fields & Properties
#region Constructor
public CategoriesViewModel() : base()
{
base.DisplayName = "Kategorie";
}
#endregion Constructor
#region Helpers
private void SendValue(int CategoryId)
{
Messenger.Default.Send(CategoryValueCode.AddValue + "," + CategoryId);
}
public override void Load()
{
var allCategories = (from k in db.Category select k).ToList();
_listCategoryAddValue = new ObservableCollection<CategoryAddValue>();
foreach (var i in allCategories)
{
_listCategoryAddValue.Add(new CategoryAddValue(new RelayCommand(() => SendValue(i.KategoriaId)))
{
Category = i,
ValueList = db.CategoryValue.Where(x => x.CategoryId== i.CategoryId).Select(x => x.Value).ToList()
});
}
}
#endregion Helpers
}
Model
public class CategoryAddValue
{
public Category Category { get; set; }
public List<string> ValueList { get; set; }
private ICommand _addValue;
public ICommand AddValue
{
get
{
return _addValue;
}
}
public CategoryAddValue(RelayCommand command)
{
_addValue = command;
}
}
I've got code where there's a string variable in MainWindow called "repeatNumber" - there's also two buttons in MainWindow. btn2 should open up a new window 'otherwindow' that has the repeatNumber string in it and displays the picture.
'Window1' does not contain a definition for 'getRepeatedNumber' and no extension method 'getRepeatedNumber' accepting a first argument of type 'Window1' could be found.
Can anyone help me with this? Can this be fixed without using MVVM? Code bellow:
Mainwindow.cs
public partial class MainWindow : Window
{
private string repeatNumber;
public MainWindow()
{
InitializeComponent();
string[] assignments = new string[] { "https://cdn2.iconfinder.com/data/icons/animals/48/Turtle.png", "https://cdn2.iconfinder.com/data/icons/animals/48/Butterfly.png", "https://cdn2.iconfinder.com/data/icons/animals/48/Dolphin.png", "https://cdn2.iconfinder.com/data/icons/animals/48/Elephant.png", "https://cdn2.iconfinder.com/data/icons/animals/48/Hippopotamus.png", "https://cdn2.iconfinder.com/data/icons/animals/48/Panda.png" };
Random rnd = new Random();
string[] randomingArray = assignments.OrderBy(x => rnd.Next()).ToArray();
List<Images> animals = new List<Images>();
for (int i = 1; i < 100; i++)
{
if (i == 9)
{
repeatNumber = randomingArray[i % randomingArray.Length];
animals.Add(new Images() { Source = repeatNumber, Number = i });
}
else if ((i % 9) == 0)
{
animals.Add(new Images() { Source = repeatNumber, Number = i });
}
else
{
animals.Add(new Images() { Source = randomingArray[i % rnd.Next(1, 5)], Number = i });
}
ItemsControl1.ItemsSource = animals;
}
}
private void btn1_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("test");
}
private void btn2_Click(object sender, RoutedEventArgs e)
{
Window1 otherwindow = new Window1();
otherwindow.Show();
string value = otherwindow.getRepeatedNumber; <--- This line gives me the error
}
}
class Images
{
public int Number { get; set; }
public string Source { get; set; }
}
Mainwindow.xaml
<Grid>
<ListBox x:Name="ItemsControl1">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="5">
</UniformGrid>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Black" BorderThickness="3" Width="Auto" Height="Auto">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Number}"/>
<Image Source="{Binding Source}" Margin="0,0,5,0"/>
</StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Grid>
<Button x:Name="btn1" Click="btn1_Click" Height="20" VerticalAlignment="Bottom" Margin="127,0,316,0" Content="Instruction"></Button>
<Button x:Name="btn2" Click="btn2_Click" Height="20" VerticalAlignment="Bottom" Margin="300,0,109,0" Content="Results" Width="74"></Button>
</Grid>
</Grid>
Window1.cs
public class Window2 : Window
{
public string getRepeatedNumber { get; set; }
public Window2(string repeatNumber)
{
getRepeatedNumber = repeatNumber;
}
}
and Window1.xaml is just
<Grid>
</Grid>
I have two Controls on a single Page :
1. RadSlider
2. ListBox
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="100"></RowDefinition>
</Grid.RowDefinitions>
<telerik:RadSlideView Name="imgSlidView" >
<telerik:RadSlideView.ItemTemplate>
<DataTemplate>
<Image Source="{Binding Src}"></Image>
</DataTemplate>
</telerik:RadSlideView.ItemTemplate>
<telerik:RadSlideView.ItemPreviewTemplate>
<DataTemplate>
<telerik:RadBusyIndicator></telerik:RadBusyIndicator>
</DataTemplate>
</telerik:RadSlideView.ItemPreviewTemplate>
</telerik:RadSlideView>
<ListBox Grid.Row="1" Name="lstImage">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Image Height="100" Margin="0,0,5,0" Source="{Binding Src}"></Image>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I want to bind the two controls to a single Item Source such that if selection of one changes other's selection also should change . I am interested in MVVM based solution.
My code :
class CategoryViewModel : ViewModelBase
{
public ObservableCollection<ImageSource> ImageCollection { get; set; }
private ImageSource _CurrentImage;
public ImageSource CurrentImage
{
get { return _CurrentImage; }
set
{
_CurrentImage = value;
RaisePropertyChanged("CurrentImage");
}
}
}
In addition to this I have a piece of code that returns IEnumerable and I want this to be as Item Source.
public static async Task<IEnumerable<Object>> GetCategoryNames()
{
if (Categories == null)
{
JDir dir = Newtonsoft.Json.JsonConvert.DeserializeObject<JDir>(await LoadFromJson());
Categories = ConvertJDirToCategory(dir);
return Categories.Select(p => new { Name = p.Name, Src = "Images/" + p.Name + ".jpg" });
}
else
{
return Categories.Select(p => new { Name = p.Name, Src = "Images/" + p.Name + ".jpg" });
}
}
Am I doing in right way ? How should I proceed ?
Thanks in advance !
EDIT - from comments:
private static async Task<string> LoadFromJson()
{
string theData = string.Empty;
StorageFile file = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///data.json"));
using (StreamReader streamReader = new StreamReader(await file.OpenStreamForReadAsync()))
{
return await streamReader.ReadToEndAsync();
}
}
Thanks every body, My problem has been solved now :
XAML :
DataContext="{Binding Category, Source={StaticResource Locator}}"
Two Controls :
<telerik:RadSlideView Name="imgSlidView" SelectedItem="{Binding SelectedItem,Mode=TwoWay}" ItemsSource="{Binding Images}">
<telerik:RadSlideView.ItemTemplate>
<DataTemplate>
<Image Source="{Binding}">
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu IsZoomEnabled="False" OpenGesture="Tap">
<telerik:RadContextMenuItem Tap="RadContextMenuItem_Tap" Content="Share">
</telerik:RadContextMenuItem>
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
</Image>
</DataTemplate>
</telerik:RadSlideView.ItemTemplate>
<telerik:RadSlideView.ItemPreviewTemplate>
<DataTemplate>
<telerik:RadBusyIndicator></telerik:RadBusyIndicator>
</DataTemplate>
</telerik:RadSlideView.ItemPreviewTemplate>
</telerik:RadSlideView>
<ListBox Grid.Row="1" ScrollViewer.HorizontalScrollBarVisibility="Auto" Name="lstImage" SelectedItem="{Binding SelectedItem,Mode=TwoWay}" ItemsSource="{Binding Images}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Image Height="100" Margin="0,0,5,0" Source="{Binding}">
</Image>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
View Model :
public class CategoryViewModel : ViewModelBase
{
private string _CategoryName;
public string CategoryName
{
get { return _CategoryName; }
set
{
DispatcherHelper.CheckBeginInvokeOnUI(() => { Set<string>(ref _CategoryName, value); });
}
}
private Uri _SelectedItem;
public Uri SelectedItem
{
get { return _SelectedItem; }
set
{
DispatcherHelper.CheckBeginInvokeOnUI(() => { Set<Uri>(ref _SelectedItem, value); });
}
}
private ObservableCollection<Uri> _Images;
public ObservableCollection<Uri> Images
{
get { return _Images; }
set { Set<ObservableCollection<Uri>>(ref _Images, value); }
}
public CategoryViewModel()
{
CategoryName = string.Empty;
Images = new ObservableCollection<Uri>();
}
}
XAML.cs
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
string Category = string.Empty;
NavigationContext.QueryString.TryGetValue("category", out Category);
if (this.DataContext is CategoryViewModel)
{
var vm = (CategoryViewModel)this.DataContext;
vm.Images.Clear();
JSONHelper.LoadFromJson().ContinueWith(t =>
{
vm.CategoryName = Category;
var images = t.Result.Dirs.FirstOrDefault(p => p.DirName == Category).Files;
Dispatcher.BeginInvoke(() =>
{
foreach (var img in images)
{
vm.Images.Add(new Uri(string.Format("Data/{0}/{1}", Category, img), UriKind.Relative));
}
});
});
}
}
I have no Binding errors in my output window.
I want to bind text from a file(s) to one/many avalonEdit controls via MVVM.
How can I do that, because its not working the way I tried?!
VIEW
>
<Window.Resources>
<DataTemplate x:Key="NormalTemplate">
<Expander Margin="0" Header="{Binding FileName}">
<!--<TextBox TextWrapping="Wrap" AcceptsReturn="True" IsReadOnly="True" Text="{Binding Content}" Margin="0"/>-->
<avalonEdit:TextEditor Document="{Binding Document, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></avalonEdit:TextEditor>
</Expander>
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40px"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid Background="Orange">
<StackPanel Orientation="Horizontal">
<Button>Run</Button>
<Button Command="{Binding SaveCommand}">Save</Button>
</StackPanel>
</Grid>
<Grid Grid.Row="1">
<ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ItemsControl ItemsSource="{Binding ErrorLogs}" HorizontalContentAlignment="Stretch" ItemTemplate="{DynamicResource NormalTemplate}" />
</ScrollViewer>
</Grid>
</Grid>
</Window>
VIEWMODEL
public class ErrorLogViewModel : BaseViewModel
{
public string FileName { get; set; }
public string Content { get; set; }
private TextDocument _document = null;
public TextDocument Document
{
get { return this._document; }
set
{
if (this._document != value)
{
this._document = value;
RaisePropertyChanged("Document");
}
}
}
}
public class MainViewModel : BaseViewModel
{
public MainViewModel()
{
GetErrorLogs();
SaveCommand = new RelayCommand(Save);
}
public RelayCommand SaveCommand { get; private set; }
private void Save()
{
var text = ErrorLogs[0].Document.Text;
// I get at least the Original loaded text
}
private void GetErrorLogs()
{
for (int i = 0; i < 30; i++)
{
using (FileStream fs = new FileStream("text.txt", FileMode.Open, FileAccess.Read, FileShare.Read))
{
using (StreamReader reader = FileReader.OpenStream(fs, Encoding.UTF8))
{
var doc = new TextDocument(reader.ReadToEnd());
var e = new ErrorLogViewModel { FileName = "ErrorLog " + i, Document = doc };
ErrorLogs.Add(e);
}
}
}
}
private ObservableCollection<ErrorLogViewModel> _errorLogs = new ObservableCollection<ErrorLogViewModel>();
public ObservableCollection<ErrorLogViewModel> ErrorLogs
{
get { return _errorLogs; }
set
{
_errorLogs = value;
this.RaisePropertyChanged("ErrorLogs");
}
}
}
I have looked at that sample were MVVM is introduced:
http://www.codeproject.com/Articles/570313/AvalonDock-Tutorial-Part-AvalonEdit-in-Avalo
I do the same binding actually when I load a text file but my text is just not shown :/
You can find here a repro visual studio solution:
http://www.file-upload.net/download-9067428/ExpanderTest.7z.html
I currently have the data for my application stored in an Azure Mobile Service SQL Database. I am pulling items from the database and displaying them in a List View. When a user clicks on an item in the list view they are then navigated to a new page that displays more details about the specific record from the database.
Main Page Code:
public class OSVersions
{
[JsonProperty(PropertyName = "id")]
public int id { get; set; }
[JsonProperty(PropertyName = "Version")]
public string Version { get; set; }
[JsonProperty(PropertyName = "Codename")]
public string Codename { get; set; }
[JsonProperty(PropertyName = "Publish")]
public bool Publish { get; set; }
[JsonProperty(PropertyName = "ReleaseDate")]
public DateTime ReleaseDate { get; set; }
[JsonProperty(PropertyName = "Changes")]
public string Changes { get; set; }
[JsonProperty(PropertyName = "Notes")]
public string Notes { get; set; }
}
public partial class OSMainVIew : PhoneApplicationPage
{
private MobileServiceCollection<OSVersions, OSVersions> items;
private IMobileServiceTable<OSVersions> osTable =
App.MobileService.GetTable<OSVersions>();
public OSMainVIew()
{
InitializeComponent();
}
private async void RefreshOSItems()
{
progressBar1.IsEnabled = true;
progressBar1.IsIndeterminate = true;
items = await osTable
.Where(OSItem => OSItem.Publish == true)
.ToCollectionAsync();
MainListBox.ItemsSource = items;
progressBar1.IsEnabled = false;
progressBar1.Visibility = System.Windows.Visibility.Collapsed;
progressBar1.IsIndeterminate = false;
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
RefreshOSItems();
}
private void MainListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (MainListBox.SelectedIndex == -1)
return;
NavigationService.Navigate(new Uri("/ViewModels/OS/OSItemView.xaml?selectedItem=" + MainListBox.SelectedIndex, UriKind.Relative));
MainListBox.SelectedIndex = -1;
}
}
Item Page Code:
public partial class OSItemView : PhoneApplicationPage
{
private MobileServiceCollection<OSVersions, OSVersions> items;
private IMobileServiceTable<OSVersions> osTable =
App.MobileService.GetTable<OSVersions>();
public OSItemView()
{
InitializeComponent();
if ((Application.Current as App).IsTrial)
{
//textBlock1.Text = "Change Log available in full version only!";
//textBlock2.Visibility = System.Windows.Visibility.Collapsed;
}
}
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
string selectedIndex = "";
int buildID;
int idValue;
if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedIndex))
{
//Start progressBar
progressBar1.IsEnabled = true;
progressBar1.IsIndeterminate = true;
//Convert selectedIndex -> buildID
idValue = Convert.ToInt32(selectedIndex);
buildID = idValue + 1;
/* buildID = idValue + 1 becuase on OSMainView
* Items stored in the ListBox are each even an index number
* The first number is '0'
* This is a problem because the first IDNumber in the Database is '1'
* This isn't the best way to handle this, becuase even though the id field is an auto-increamental field,
* sometimes values are skipped and rows are deleted.
*/
//Query database
items = await osTable
.Where(OSItem => OSItem.id == buildID)
.ToCollectionAsync();
MainListBox.ItemsSource = items;
//End progressBar
progressBar1.IsEnabled = false;
progressBar1.Visibility = System.Windows.Visibility.Collapsed;
progressBar1.IsIndeterminate = false;
}
}
}
Items Page XAML Code:
<Grid x:Name="ContentPanel" Margin="10,97,12,0" Grid.RowSpan="2">
<ListBox x:Name="MainListBox" Margin="10,-35,-12,0">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,0" Width="432" Height="*">
<TextBlock TextWrapping="Wrap" Text="{Binding Version}" Style=" {StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock Text="Notes" FontFamily="Segoe WP Bold" Foreground="{StaticResource PhoneAccentBrush}" Height="30" HorizontalAlignment="Left" Margin="0,1,0,0" Name="textBlock3" Padding="0" VerticalAlignment="Top" Width="444" />
<TextBlock x:Name="notesText" Text="{Binding Notes}" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}" Height="180" VerticalAlignment="Top" HorizontalAlignment="Stretch" FontFamily="Segoe WP SemiLight" Margin="0" Width="455"/>
<TextBlock Text="Change Log" Height="30" HorizontalAlignment="Left" Margin="0,222,0,0" Name="textBlock1" VerticalAlignment="Top" FontFamily="Segoe WP Bold" Foreground="{StaticResource PhoneAccentBrush}" Width="444" Padding="0" />
<TextBlock Name="textBlock2" Text="{Binding Changes}" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap" Height="Auto" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" FontFamily="Segoe WP SemiLight" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
My problem occurs when MainListBox.ItemsSource = items; is executed.
The application quits without any error codes.
Any ideas?
The problem had to due with the Height of the StackPanel being set to '*'. After removing that, the problem was solved.