WP7 - Progress Bar - c#

What is the best way to structure a ProgressBar using Blend?
Right now I have
LayoutRoot > Panorama > PanoramaItem > ListBox
I want to have a progress bar 'behind' the ListBox, and hide it when my web request finishes. So, should I put the ListBox & ProgressBar into a StackPanel? Or should I just programatically add or remove the ListBox / ProgressBar?
I just want to do this the best way possible. Most of the tutorials I find are for progress bars that are just underneath an area of fixed height, and hid when loading completes.

With Windows Phone 7.5 you should use the SystemTray-class with the new ProgressIndicator property. It enables you to provide a progress indicator quick and easy and with a consistent look'n'feel for the user at the top of your screen. This would be the best user-experience possible (see image below) :-)
If you want to show the progressbar nevertheless in the middle of the empty ListBox you can arrange both controls for example with a Grid and toggle the visibility as you need it. Removing and re-creating those controls isn't recommened because it would use a much larger overhead in the background and may be not very performant. But as mentioned above it would be best-practice to use the system tray for status information, including the ProgressBar.
But wether you use the SystemTray-Class or using a ProgressBar control, you shouldn't only toggle the visibility, but also toggle the IsIndeterminate property - it's using resources when "true", even if the ProgessIndicator isn't visible!

Related

best way to create a fancy log

I have a 'log' in my application. Currently I'm using richtextbox control to display colored text. The problem I want to have a simple animation from background images in the background. According to this answer: Can a background image be set on a Winforms TextBox? it's not recommended. I could use datagridview for log, but it flickers when new items are added and it makes it look unstable and ugly. What would be a good way on winforms to display colored text in log and have a background image? Thanks!
If you want something that is easy and looks at least decent your best bet is probably to use WPF Interop (ElementHost) and build the control in WPF. Winforms constrols are a real headache for this type of application.
The WPF TextBox already supports a background image and renders it well.
In your WinForms Project : Right-click, "Add" --> "New Item..."
Select "WPF" --> "UserControl".
Drag a WPF TextBox onto the control, set up background image as you like, etc.
In your Winforms form --> "WPF Interoperability" (in Tools pane) --> drag "ElementHost" to your form.
Set the "Selected Host Content" to your new WPF user control.
Job done.

Enable scroll bar from disabled listview in C#

I'm getting confusion. I'm set :
this.listView1.Enabled = false;
when i make do that listview's scroll bars are disabled, too. I want to see all listviewitems in listview with scroll bars when listview disabled. Please give me some advices. Thanks.
After a lot of comments, I'm assuming your listview, because of is updated often from many different threads, is flickering.
If so, one possible solution is to enable DoubleBuffering; this property anyway is protected so accessible only from descendant classes.
So you could:
Add a new class to your project and paste the code shown below
Compile
Drop new control from the top of the toolbox onto your form, replacing the old one
This could solve your problem.
using System;
using System.Windows.Forms;
class BufferedListView : ListView
{
public BufferedListView()
{
this.DoubleBuffered = true;
}
}
The idea is taken from this post on SO.
you can't scroll a disabled control, since scrollbars are part of the control itself (and it's disabled, so...).
if you want to scroll but not allow user to select anything, you could do this
this.listBox1.SelectionMode = SelectionMode.None;
if you want to revert it, you can set it to SelectionMode.One for single, or one of the other options for multiple selection allowance.
another (imho overcomplicated) option is making a user drawn ListBox.
You can't scroll a disabled control - but if you really need such a functionality, develop a user control.
Developing Custom Controls in C#
Hiding the scroll bar in CheckListbox
Writing your custom control step by step.
Maybe if you put your listview inside a Panel you can enable scrolling by setting up ScrollBars="Auto" on the Panel control

What would be the best course of action for display different form in a single Winform?

Here's a screenshot of my application:
Basically, depending on what option is selected I'd like to show another 'content' which can be a buttons, or forms or whatever.
What would be the best choice for this? Using MDI? I'm really new to this type of thing.
This scenario lends itself well to tab pages, as you'd find on a TabControl.
However, since you already have a mechanism for switching between the content, you might prefer to create a series of Panels whose Dock property is set to DockStyle.Fill. When the user clicks the appropriate heading, you simply need to show the appropriate panel and call BringToFront() on it. This is essentially what the tab control does internally, anyway.
Don't forget to use SuspendLayout() and ResumeLayout() appropriately to reduce flicker, which can be a huge problem in WinForms applications, especially when there are lots of controls.
You can position a TabControl where the buttons are not visible and control it from your buttons.

Winforms Creating Dropdown style panel

I am attempting to create my own custom Autocomplete style dropdown control in c# .net2.0. For speed of development I have built my control as a UserControl but have hit on an issue of doing it this way.
When the custom drawn dropdown gets drawn I have to resize the UserControl area to be able to display the list of options.
Ideally I want to be able to mimic the drodpown list behaviour in that the list of options is drawn 'floating' and is not constrained by the UserControls height and width (nor even the parent forms boundaries). A tooltip is another example of the unconstrained 'floating' that I desire.
The only way I can think of achieving this is to create on the fly a new form with no border or title bar and display this when the popup is required.
Is there a better (but also quick) way of doing this?
TIA
You would need to use a Form or NativeWindow to allow the control to float correctly. To make a form follow the control is easy enough but it is more difficult to implement and handle all of the focusing/hiding issues especially if you need seamless tabbing/key navigation.
You can try creating a control that is based off the ToolStrip Drop Down Button control. I believe that this control has the functionality that you are looking for. I found this reference for creating controls based off the ToolStrip, you might try starting with this.
http://blogs.msdn.com/jfoscoding/attachment/1335869.ashx

Dynamic top down list of controls in WindowsForms and C#?

In our project, SharpWired, we're trying to create a download component similar to the download windows in Firefox or Safari. That is, one single top down list of downloads which are custom controls containing progress bars, buttons and what not.
The requirements are that there should be one single list, with one element on each row. Each element must be a custom control. The whole list should be dynamically re-sizable, so that when you make it longer / shorter the list adds a scroll bar when needed and when you make it thinner / wider the custom controls should resize to the width of the list.
We've tried using a FlowLayoutPanel but haven't gotten resizing to work the way we want to. Preferably we should only have to set anchoring of the custom controls to Left & Right. We've also thought about using a TableLayoutPanel but found adding rows dynamically to be a too big overhead so far.
This must be quite a common use case, and it seems a bit weird to me that the FlowLayoutPanel has no intuitive way of doing this. Has anyone done something similar or have tips or tricks to get us under way?
Cheers!
/Adam
If you don't want to use databinding (via the DataRepeater control, as mentioned above), you could use a regular Panel control and set its AutoScroll property to true (to enable scrollbars).
Then, you could manually add your custom controls, and set the Dock property of each one to Top.
.NET 3.5 SP1 introduced a DataRepeater Windows Forms control which sounds like it'd do what you want. Bind it to the list of "downloads" (or whatever your list represents) and customize each item panel to include the controls you need.

Categories

Resources