What we do in commnads in older side menu is that we put the "uiid" in putClientProperty() method but it doesn't work in ontop side menu. How to style it?
Command services = new Command(" Services", servicesIcon) {
#Override
public void actionPerformed(ActionEvent evt) {
}
};
f.getToolbar().addCommandToSideMenu(services);
services.putClientProperty("uiid", "commandProp");
It still works but because the side menu is constructed eagerly instead of lazily you don't see this.
Instead of this:
f.getToolbar().addCommandToSideMenu(services);
services.putClientProperty("uiid", "commandProp");
Do:
services.putClientProperty("uiid", "commandProp");
f.getToolbar().addCommandToSideMenu(services);
Related
The text in side menu command exceeds the width of the side menu, which makes somewhat peculiar effect.
see the video here
How can I set multiline as in textArea in this case?
Command protectedPlantAndSpecies = new Command(" Protected plants and species of nepal", protectedPlantIcon) {
#Override
public void actionPerformed(ActionEvent evt) {
new Notification(res).show();
}
};
f.getToolbar().addCommandToSideMenu(protectedPlantAndSpecies);
This is tickering which is enabled by default, you can disable it by calling this in your init(Object) method:
Label.setDefaultTickerEnabled(false);
You can also set the theme constant tickerSpeedInt to 0.
I have an app that has a nice side menu that comes from the left, after today's update it is completely empty when it slides out and I have no idea why.
here is how I show it,
SideMenuBar smb = (SideMenuBar) Display.getInstance().getCurrent().getMenuBar();
smb.openMenu(null);
Here is how it is created (remember this worked perfectly until today when I updated libs):
private void addSideMenuToLeft(Form f)
{
_("addSideMenuToLeft");
//make a toolbarForLeftMenu so we can use its sidemenu (we can only have one on the left!)
if (toolbarForLeftMenu==null)
{
toolbarForLeftMenu = new Toolbar();
}
toolbarForLeftMenu.setHidden(true);
f.setToolbar(toolbarForLeftMenu);
if (SideMenuLEFT==null) //otherwise it keeps adding each time
{
SideMenuLEFT = (Container)this.createContainer(resources, "SideMenuLEFT");
SideMenuLEFT.setWidth(Display.getInstance().getDisplayWidth()/2);
SideMenuLEFT.setHeight((Display.getInstance().getDisplayHeight()));
SideMenuLEFT.setUIID("SideNavigationPanel");//so we get the nice background.
toolbarForLeftMenu.setUIID("Container");
toolbarForLeftMenu.addComponentToSideMenu(SideMenuLEFT);
//make each button live, there are 2 buttons the icon and the words, for each one
Button btCategory = (Button) Tools.findByNameX("btCategory", SideMenuLEFT,sm );
btCategory.addActionListener(new ActionListener(){
#Override
public void actionPerformed(ActionEvent evt) {
}
});
_("made left menu");
}
}
We deprecated the SideMenuBar and replaced it with the new on-top side menu. It was announced multiple times and discussed quite a bit.
To disable this and use the "old" functionality you can use:
Toolbar.setOnTopSideMenu(false);
i have added the following codes for pull2refresh but the run method is not called. I have tested for form and its ok for form. How to make it workable for tabs so that I can update all tab at once . and I have pull2refresh of form for whole for refresh.
findTabs1(f).getContentPane().addPullToRefresh(new Runnable() {
#Override
public void run() {
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
//
}
});
Tab doesn't have contentPane but TabbedPane.
To add pullToRefresh to a tab, you should add it to the container you added to the tab and it must be scrollable-Y.
Instead of findTabs1(f).getContentPane().addPullToRefresh do findMyContainerInsideTab().addPullToRefresh
I am having trouble using the WPF Extended Toolkit (version 2.1.0.0) MessageBox from other threads. The namespace is: Xceed.Wpf.Toolkit.MessageBox
I replaced my regular MessageBoxs (System.Windows.MessageBox) with the Toolkit MessageBox and get errors when I launch one from another thread. The System.Windows.MessageBox has no such problems. I saw this posting that reports the problem, but there seems to be no follow up:
https://wpftoolkit.codeplex.com/workitem/21046
I'm guessing there is a work around. An example is presented there that shows the problem, but here is my simple example:
First, I wrap the Toolkit.MessageBox. I do this primarily because I'm applying style (although I've commented that out to show that's not the problem)
public class CustomMessageBox
{
//static DummyUserControl1 _ctrl = new DummyUserControl1();
public static MessageBoxResult Show(string msgText, Style styleArg = null)
{
Cursor saveCursor = Mouse.OverrideCursor;
Mouse.OverrideCursor = null;
//Style style = styleArg != null ? styleArg : _ctrl.FindResource("MessageBoxStyle1") as Style;
// MessageBoxResult result = Xceed.Wpf.Toolkit.MessageBox.Show(msgText, "", MessageBoxButton.OK, style);
MessageBoxResult result = Xceed.Wpf.Toolkit.MessageBox.Show(msgText, "", MessageBoxButton.OK);
Mouse.OverrideCursor = saveCursor;
return result;
}
}
The main window just has two buttons on it, and here's the code behind:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void btnMainThreadMsgBox_Click(object sender, RoutedEventArgs e)
{
CustomMessageBox.Show("Hello on main thread");
}
private void btnAltThreadMsgBox_Click(object sender, RoutedEventArgs e)
{
Thread altThread1 = new Thread(new ThreadStart(AltThread1Proc));
altThread1.SetApartmentState(ApartmentState.STA);
altThread1.Priority = ThreadPriority.AboveNormal;
altThread1.IsBackground = true;
altThread1.Start();
}
public void AltThread1Proc()
{
MessageBox.Show("Hello on Alt Thread");
CustomMessageBox.Show("Hello on alt thread");
}
}
The problems occur in AltThreadProc() with CustomMessageBox.Show(...). The curious behavior I referred to is this: If you hit the main thead button and then the Alt thread button, you get the error:
Cannot access Freezable 'System.Windows.Media.SolidColorBrush' across threads because it cannot be frozen.
However, if you skip the main thread button and just hit the Alt thread button, you get the error:
The calling thread cannot access this object because a different thread owns it.
I'm curious what the "Freezable" error is all about and why you can get different errors based on what would seem to be an innocuous event: clicking/not clicking button that produces message box on main thread.
Ideally, it would be nice to just replace System.Windows.MessageBox with Xceed.Wpf.Toolkit.MessageBox, but if there is some sort of extra code to write, that might be acceptable. The documentation, and the link I provided hints at using a WindowContainer, but I can't really see any examples of how you do that. I was attracted to the Toolkit MessageBox as it allows one to do some cool stuff with MessageBox (which I don't show here) such as apply styles, change the text of the OK, CANCEL button, etc.
Any ideas would be much appreciated.
Thanks,
Dave
Extra info:
User1341210 suggestion works well if you just have one window. However, if you have a second window in it's own thread it doesn't work so well. Perhaps someone can tell me what I'm doing wrong. I use the suggestion of the TaskScheduler, but the code throws an exception if the TaskScheduler used is the one of the second window. That is, all works fine if I use the TaskScheduler of the first window, but throws an exception if I use the TaskScheduler of the second window. Here is the code behind for my second window:
public partial class AltThreadWindow : Window
{
private TaskScheduler _ui;
public AltThreadWindow()
{
InitializeComponent();
_ui = TaskScheduler.FromCurrentSynchronizationContext();
}
// This constructor is for passing in the TaskScheduler of the mainwindow and works great
public AltThreadWindow(TaskScheduler scheduler)
{
InitializeComponent();
_ui = scheduler;
}
private void btnWindowsMsgBox_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("Standard Windows message box");
}
private void btnCustomMsgBox_Click(object sender, RoutedEventArgs e)
{
MessageBoxResult result;
Task.Factory.StartNew(() => { result = CustomMessageBox.Show("Custom MessageBox on separate window"); }, CancellationToken.None,
TaskCreationOptions.None,
_ui);
}
}
Notice the two constructors. The default one assigns the TaskScheduler of the second window. The other constructor allows one to pas in the TaskScheduler of the main Window.
Here's the code I use to launch the second window from the main window. Again, I'm launching the second window on another thread, and I pass in the TaskScheduler of the main window. It would be nice to use the TaskScheduler of the second window instead.
_altWindowThread = new Thread(new ThreadStart(AltWinThreadProc));
_altWindowThread.SetApartmentState(ApartmentState.STA);
_altWindowThread.Priority = ThreadPriority.AboveNormal;
_altWindowThread.IsBackground = true;
_altWindowThread.Start();
And the actual threadproc:
[EnvironmentPermissionAttribute(SecurityAction.LinkDemand, Unrestricted = true)]
public void AltWinThreadProc()
{
// Create our context, and install it:
SynchronizationContext.SetSynchronizationContext(
new DispatcherSynchronizationContext(
Dispatcher.CurrentDispatcher));
_altWindow = new AltThreadWindow(_ui);
_altWindow.Show();
System.Windows.Threading.Dispatcher.Run();
}
Notice here I pass in the TaskScheduler of the MainWindow.
we had the same issue in our application (I created the work item on codeplex).
The error messages are quite confusing and I cant provide you an answer to that.
But:
We didn't used a separated WindowContainer to solve it. Instead came up with calling the separate task/thread with the UI scheduler:
Task.Factory.StartNew(
() => { result = CustomMessageBox.Show(messageText); },
CancellationToken.None,
TaskCreationOptions.None,
_ui);
Where _ui is assigned in a method that is executed from UI context (e.g. Constructor of your Window/Control:
_ui = TaskScheduler.FromCurrentSynchronizationContext();
Hope this helps for solving the "replace System.Windows.MessageBox with Xceed.Wpf.Toolkit.MessageBox" part of your question.
If you want that the messagebox shows up on another Window you have to set the "Owner" property of the message box to the other window.
Best regards.
Silverlight 3 allows you to run your application out of the browser, which installs a link on your desktop/start menu.
The problem is we are currently using
System.Windows.Browser.HtmlPage.
Window.Navigate(new Uri("http://<server>/<resource>"), "_blank")
to load a URL into a new browser window (it's to provide a 'print friendly' page for users to print). This works in the normal SL in-browser version, but outside the browser we get 'The DOM/scripting bridge is disabled.' exception thrown when issuing the call.
Is there an alternative which works out of the browser?
I've seen Open page in silverlight out of browser but I need to do this entirely in code, so I don't want to add a (hidden) hyperlink button and then programmatically 'click' it (unless I absolutely have to...).
you can try inheriting from HyperlinkButton and exposing public Click() method (which you can then instantiate and call from code instead of declaring it in xaml).
Details here: http://mokosh.co.uk/post/2009/10/08/silverlight-oob-open-new-browser-window/
I wrote an Extension method based on the idea to inherit from the HyperlinkButton.
public static class UriExtensions {
class Clicker : HyperlinkButton {
public void DoClick() {
base.OnClick();
}
}
static readonly Clicker clicker = new Clicker();
public static void Navigate(this Uri uri) {
Navigate(uri, "_self");
}
public static void Navigate(this Uri uri, string targetName) {
clicker.NavigateUri = uri;
clicker.TargetName = targetName;
clicker.DoClick();
}
}
Then use can use it simple, like
new Uri("http://www.google.com").Navigate("_blank");