• /r/csharp
  • [Windows Store]Creating Custom UI elements

    I need something that is a button, but has StackPanel as a child with a few different objects: <Button HorizontalAlignment="Stretch"> <StackPanel Margin="10"> <TextBlock Name="sName" FontWeight="Bold" FontSize="15">Name</TextBlock> <TextBlock Name="sDesc" FontSize="13" TextWrapping="WrapWholeWords">Desctiption</TextBlock> <ProgressBar Name="sProgress" Height="18" /> </StackPanel> </Button> Something like the code above. I would like to be able to instantiate it with one line of code […]

  • /r/csharp
  • Which way of displaying images offers better performance?

    I'm having an issue with performance when displaying a lot of images in a winRT app. So i've come here for some help. For regular bitmaps, which way is better for memory management? bitmapImage = new BitmapImage(); bitmapImage .UriSource = new Uri(this.BaseUri, pathToImage); OR using (Stream picture = await InstallationFolder.OpenStreamForReadAsync(storageFileOfImage)) { await bitmapImage.SetSourceAsync(picture.AsRandomAccessStream()); picture.Dispose(); } […]

  • /r/csharp
  • I’m getting “System.InvalidCastException: Specified cast is not valid.”

    With the line "cmdThisIDTest = ((int)commandThisID.ExecuteScalar());" in the code below I'm getting "System.InvalidCastException: Specified cast is not valid." How do I fix this? Thanks. using (var conn = new SqlCeConnection(dbConnectionString)) { conn.Open(); var commandThisID = new SqlCeCommand("SELECT MAX(thisID) FROM table1"); commandThisID.Connection = conn; object ThisIDTest = commandThisID.ExecuteScalar(); int cmdThisIDTest = 0; if (ThisIDTest != null) […]