I have to increase height of windows form after I clicked one button.
I need to do this programmatically cause I try to do this with xml code and did it well ,but it work every time I click button, I need to animate just once with clicking just one button
you can use double animation to change the height property.In your button_click event write the code for double animation.
DoubleAnimation dblanim = new DoubleAnimation();
dblanim.To =200;
dblanim.Duration = TimeSpan.FromSeconds(3);
this.BeginAnimation(HeightProperty, dblanim);
use dblanim.To property to set the height of your window.
Related
I've dynamically created a horizontal scrolling list of labels (with icon and bottom text) within a container in a tab.
However, I cannot seem to bind any action to this Label - I want touch, long press, options(commands), drag, etc
If I use Button instead of Label, I cannot seem to use URLImage to grab the icon from a url and save it to storage and use that as the button icon. It always uses only the placeholder from:
Image img = URLImage.createToStorage(placeholder, counter+"_thumbnail", thumbnailURL, URLImage.RESIZE_SCALE);
How do I grab events on the Labels? Here is a snippet of how I'm adding the labels to the container:
Container c = StateMachine.instance.findFirstListContainer();
for(...){
Label l = new Label();
l.setText(title);
l.setIcon(img);
l.setUIID("listItem");
l.setTextPosition(2);
c.addComponent(l);
}
You should use a Button rather than a Label and invoke the setUIID("Label") method.
The reason why you didn't do this is a separate question/issue: https://groups.google.com/d/msg/codenameone-discussions/5HoDEFjB5II/5dc4iKuYNSYJ
I have a button and I want it to be always at the same location on my form (top-left corner of visible part of the form).
Here is the example:
So when I scroll vertically or horizontally, the button should always be at the top-left corner and it should be visible.
What should I do to make it fixed?
I guess you are using Form's AutoScroll feature.
What about placing Panel with AutoScroll = true on the form and use its scrolling instead? Then you will be able to place a button on a form but over this scrollable panel. So, the scroll rulers will scroll the view panel contents, but the button will stay pinned to the form.
If you don't want to add another container component, then you can add a handler on Scroll event and adjust the button position in response to form scrolling. The ScrollEventArgs argument has ScrollOrientation, NewValue and OldValue to calculate new X/Y position of the control.
On the form, you place a Panel and set: its Dock property to Fill, and AutoScroll property to True.
You place all the other controls inside this panel, but not the button you want to keep visible.
Right-click on the panel->Send-to-Back.
The Panel will adjust the size to match the form; the scrolling will only happen in the panel, so the button will always stay visible(you can set Anchor:Left,Top on it)
In order to be able to scroll(with the mouse wheel), the focus must be on a control inside the scrollable area(inside the Panel), NOT on the button. To prevent the button from getting focus: set TabStop to false on it; also, when it is clicked, you must also set the focus on an other control, by calling:
this.SelectNextControl(the_button, true, true, true, true);
I am using following code to set gray light effect on window when I open a popup. It works fine but it basically reloads all controls or refreshes the main window .
Especially this line: currentWindow.Content = lightboxGrid;
Window currentWindow = Application.Current.Windows.Cast<Window>()
.SingleOrDefault(x => x.Name.Equals(MAIN_WINDOW_NAME));
Grid lightboxGrid = new Grid();
object currentWindowContent = currentWindow.Content;
currentWindow.Content = null;
lightboxGrid.Children.Add(new ContentControl()
{
Content = currentWindowContent
});
// now add the grid that will "black out" the content
Grid blackoutGrid = new Grid();
blackoutGrid.Background = new SolidColorBrush(Colors.Black);
lightboxGrid.Children.Add(blackoutGrid);
blackoutGrid.Opacity = 0.0; // start fully transparent
blackoutGrid.Loaded += blackoutGrid_Loaded;
currentWindow.Content = lightboxGrid;
this._lightboxEffectApplied = true;
What could be the option to have the same effect without refreshing the main window or reloading the controls?
If your main window has a Grid as its layout root (even if all the content is in the first cell), then you could add this blackoutGrid as a child to that grid and it will display above the other elements without messing with the original visual tree structure.
In this case, the Content of your Window would be a Grid, and you would add your blackoutGrid to that Grid, and remove it when you are done.
The way you are writing this seems to be a little against object-oriented practice. Technically it should be your Main Window that has the ability to display a lightbox effect.
I want to get screenshot of screen under my form, so I hide it first and show after capturing. But on my Windows 7 form is not completely minimize, so I get form on screenshot. How can I be sure that my form is competely minimize?
WindowState = FormWindowState.Minimized;
Bitmap screenshot = ScreenUtils.ScreenShot();
background = screenshot;
WindowState = FormWindowState.Normal;
P.S. Hide() and Show() have the same problem.
you could set your forms opacity to 0, call refresh to make sure the painting is done, capture, reset opacity to 1 and call refresh again
Did you try to build in a sleep before making a screenshot?
I have a Silverlight application, containing a scrollviewer in a grid layout.
When I move the scroller down and close this grid with the close button, the scroller remains at the bottom whenever I reopen the grid.
Is there a way I can reset the scroller to the top position?
Hello supriya khamesra,
Please Try this.
Please Put your grid inside scroll viewer and then write your bellow code after grid selection change.
grdDetail.ScrollToVerticalOffset(0d);
OR
grdDetail.ScrollToTop();