I am thinking of ways to display data and what I had in mind was a sort of ticker, that users can switch between items on.
ie.
< Some text here... >
Where if the user clicks the left button, an animation causes the text to slide left and some new text to appear from the right. Likewise for clicking the right button.
Are there any existing WPF controls that would do this (I am quite new to WPF)? If not, how difficult would it be to make manually? I imagine I would need to use a storyboard to make the animation?
Thanks
Sounds like You are talking about a Carousel control. It's not hard to make your own with a use of a ItemsControl, or ListBox where you slide the selected items into the view. There are some controls out there including one made by Telerik. Here're a couple of links to get you started, but just google "WPF Carousel"
http://wpfcarousel.codeplex.com/
http://www.telerik.com/products/wpf/carousel.aspx
Related
I have a rather complex WPF XAML window, which represents a printed form.
Mainly, on top, there is a Canvas at size of an A4 page. The children of the canvas are a lot of nested StackPanels, and then again lots of labels, textblocks, textboxes, labels, check boxes, drop downs, etc.
I print the window as follows:
PrintDialog dlg = new System.Windows.Controls.PrintDialog();
if (dlg.ShowDialog() == true)
{
dlg.PrintVisual(this.PageCanvas, "Document");
}
Now, during print, I want that colors and borders of textboxes disappear. Even more, I'd even like to replace some TEXTBOXES and CHECKBOXES with TEXTBLOCKS.
a) Are there pre-built methods for switching between "screen mode" and "print mode"?
b) Or, otherwise, can I exchange certain controls at run time with textblocks ?
I want to avoid to create two variants of the same form (one for screen, one for print), because this would double all future maintenance work.
well I'm thinking probably the best thing to do would be to create another form and design it in the way u want then when u click the print button print that form... don't forget to databind the objects.... easiest method would be to use datastore.
Just for documentation: As a temporary solution, I found a way to replace a control in some panel at runtime like this:
this.somepanel.Children.Remove(this.sometextbox);
TextBlock n=new TextBlock();
n.Text = "...";
n.TextAlignment = TextAlignment.Right;
this.somepanel.Children.Add(n);
This is a solution that works; however, I'm quite sure that there are better solutions, which make better use of the whole WPF concept.
However, for the time being, I do it like this for a 1st version. For a 2nd version, I will go more in depth of WPF, and possibly post an additional answer or article.
I know that label can't receive focus, it doesn't seem to be responsive to tab switching. But all I need is perform some action when user uses tab consequently on a form which has only labels. For example, each label has an associated textbox but this textbox is hidden when the label is visible and vice-versa. What I want is allowing user to use tab to switch between the hidden textboxes on the form, normally, all the textboxes are hidden while all the labels are shown, the labels are supposed to be focusable so that when using tab, it can know that (as some event) to show the associated textbox and hide itself, when switching to another label, the current label whose the associated textbox is shown will become visible again and its associated textbox will become hidden.
I have to implement this kind of 2 in 1 control (textbox and label in a composited control) because I just want to show only the text (no border and background) as if the textbox has a transparent background and only show the textbox (and hide the label) when user need to edit (start by clicking on the field or using tab). This should have been easier for me if there was a transparent background textbox but there isn't a decent one in the world of windows forms. Please notice that I also know of the alpha blend transparent textbox presented in an article in codeproject but it can't meet my need because the text is rendered wrong with ugly border around the text path (some kind of missing antialiasing but it's even worse than that).
I'm really pity if this mechanism can't be implemented, the forms look better when all the fields seem to show info only but a click or tab switch can let user jump in edit mode.
I hope there is some solution out there. Thank you in advance.
I found this solution by a whim in my mind. I didn't think there was such a solution but it does help solve my problem (and I'm sure many others will benefit from it). Simply I have to create my own Label inheriting UserControl. I didn't thought of UserControl before and it is very helpful. Focusability, transparent background, borderlessness are all which can be done easily to a UserControl. The only custom feature I have to do myself is rendering the text which is also very simple and there are many ways to do. I just add a Label to the UserControl and set Label's Dock to DockStyle.Fill, adjust the height of the UserControl properly and that's all.
Thank God helping me think of UserControl before trying any other complicated solution such as listening to TAB and SHIFT + TAB keypress events.
Is there any built-in control like a dropdown/slider? For instance, I want to display some info on dialog/control/form and inside that form there is a arrow which expands it to show more information?
alt text http://img227.imageshack.us/img227/4945/73068794.jpg
When I click the black arrow, the form should expand vertically to show more info. That's what I want to achieve. If there isn't any built-in control, can you please tell me what do I need to do to implement it myself? And how can I add a little animation when it is expanding?
Like here (when you click the menu header it doesn't expand/contract instantly rather it does little slowly, that's the kind of animation I would like to add)
This CodeProject article should help you get started.
I'm a bit new to the C#-form app developing and I want know, what's the best way around at making a control that holds a list of horizontal items. In which each of these items are horizontally ruled to it's parent control, contain a thumbnail to the left and a large text block to the right of image and a smaller text block underneath that. So basically this isn't a predefined control I can find in the toolbox. Any ideas?
You could lay this out with Panels in form controls, or with WrapPanel and StackPanel in WPF.
In WindowsForms, I would create a user control that held the correct layout for a single item, then make a list of them at run time.
In WPF I would use a List control, but set the layout template to use WrapPanels and StackPanels.
WPf is the better solution long term if you don't have to coexist with winforms
How can I make an item inside a ToolBar fill all the remaining available space? Or, how to right-align some items, since that would give me the same effect in my case.
Note that solutions which involve nesting another container (like a Grid) inside the ToolBar don't work since that disables the special behaviour ToolBar gives to it's items (like no normal borders and look, simple outline border on hover, not receiving focus after click, etc.).
Additionally, anyone knows how to get rid of the little button that would show additional icons that overflowed from the toolbar if I had any?
I ended up using this solution:
http://karlshifflett.wordpress.com/2008/01/23/wpf-sample-series-stretch-toolbar-width-of-window/
It's not ideal, but it works. I still don't know how to get rid of the dropdown on the end though.
You can remove the button at the end by re-templating the toolbar. You can likely solve your other query this way too.
I wrote up a soluton for creating a "space filling" label that dynamically sizes to allow to you "right-align" items in a toolbar. Check it out: WPF Toolbar Items HorizontalAligment="Right"