I trying to use the Quick access toolbar on Dev Components Ribbon Bar, it works fine if I set it in the designer.
But if I change the 'CanCustomize' flag on a 'BaseItem' on the form load event the customize dialog does NOT pick this up.
I wondered if there is a command I can call to tell the ribbon bar to redefine itself?
or if I have to redefine the ribbon bar entirely?
I have tried calling RecalcLayout as beloww
BaseItem.CanCustomize = false
RibbonBar.RecalcLayout()
but it does not work.
Hi have figured out what works for this.
BaseItem.visible = false
this will stop it from being shown on the QAT, but it will still be visible on the customize menu, i still want to stop some of these being shown, but have NOT figured that out yet.
Related
I'm a university student therefore I'm not sure on everything to do with writing code. If you could provide hints or a bit of help. I have hidden the listbox via the designer. I've tried listbox1.Show under next button event handler. I've tried looking around on the web but I'm getting no where.
Now answered. Thank you
The solution depends on how you've hidden your listbox. If you did set visible property to false, just use listbox1.Visible = true;.
If you used ' Send to back' to hide it behind another control, you can use listbox1.BringToFront(); to set it into the foreground.
See https://msdn.microsoft.com/en-gb/library/system.windows.forms.control.visible.aspx and https://msdn.microsoft.com/en-gb/library/system.windows.forms.control.bringtofront.aspx
Inside Button_Click Event write:
listbox1.Visible = true;
In my opinion, the best way to show/hide controls (in WPF) is to collapse them. This allows the rest of the controls to behave as if the collapsed control does not even exists, until it is made visible, of course.
This would be done like so:
control1.Visibility = Visibility.Collapsed;
control1.Visibility = Visibility.Visible;
If you are using WinForms, controls will not have a collapse option, and the correct way would be as Almansour has said.
I have a custom addin for Word (could also be for Excel).
The addin has a ribbon with multiple groups and multiple controls (buttons) within them.
This is an ongoing project and some of the ribbon buttons are for users, and some are for testing/development purposes.
When I send the product to the client I only show certain buttons. I want the testing buttons to be completely invisible/inaccessible. I Have tried setting the testing buttons/groups to visible = false.
This works, in the sense that the buttons do not appear on the ribbon, but if the user goes to Word's quick access toolbar > "More Commands" > "Choose Commands From" dropdown and selects my custom addin...
Then the user can see all of my buttons. Even the ones with no label.
I have tried looping the controls in the ribbon load method and setting the testing controls to enabled = false, locked = true, generatemember = false, but none of these hide the buttons from the QAT menu. I also tried control.Dispose() - no joy.
Is there anyway to set the properties of a ribbon button such that it is completely invisible and inaccessible to the user in the QAT??
Many thanks
Set the ApplicationMode.
Button CommandName='cmdExportMetadata' ApplicationModes='1'
Please see the below link too :
https://msdn.microsoft.com/en-us/library/windows/desktop/dd940486(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/ee264330(v=vs.85).aspx
I would suggest you to create debug buttons dynamically. Define a constant variable like public constant string environment = "DEBUG"; and check it on start up
I have made a custom MessageBox for my application and it launches as a UserControl. I have two buttons inside it and I would like to allow users to press Tab to switch between Buttons. However, since it's a UserControl overlaying the content, Pressing tab more than twice makes the focus go in the background on elements that aren't supposed to be tabbed at.
I can't figure out a good idea how to prevent this, I've thought of making a method that will select all elements and make their IsTabStop values to false and then restore them later, but I think that would be more of a problem then a solution.
Is there a way around this to limit tabbing only to the UserControl?
I would also appreciate advice on working with the message box.. the whole messagebox is an async function that has an infinitive loop until the answer is given. Is there another way to stop the application until one of the message box options was selected?
Crowcoder's reference has lead to correct MSDN page where I found my solution:
dialog = new UCMessageBox("Are you sure you want to exit the application?", MBType.YesNo);
AppMessageBox.Children.Add(dialog);
KeyboardNavigation.SetTabNavigation(dialog, KeyboardNavigationMode.Cycle);
The key was to call .SetTabNavigation function and direct it to my dialog (custom UserControl for the message box) and setting the KeyboardNavigationMode to Cycle.
After closing the UC rest of the application continued normally regarding navigation.
I want to write a coded UI test like "Some WPF control when some condition should not be visible". How do I assert "is not visible"?
To reproduce the issue:
create new WPF app
add nothing but one big named button into the main window
go to CUIT editor and recognize the button
without closing the CUIT editor close the WPF app
add Visibility="Hidden" to the button
restart the app
select the button in the CUIT editor and press "refresh" button
NOTE: the properties of the hidden button are exactly the same as properties of visible button!
There's no way to assert that the button is hidden!
Additionally:
I would be glad to hear about workarounds you're using. After all what I need is to write the test, not figure out CUITs
I am aware that I can compare screenshots
Interestingly if you try to do stuff with the hidden button the CUIT will throw. It implies that the CUIT knows when a button is hidden.
Interestingly if Visibility="Collapsed" instead of "Hidden" CUIT will recognize it by reporting Width = Height = -1. That doesn't help with collapsed buttons though :(
I've found the best way to work around the IsVisible limitation is to use the TryGetClickablePoint(out System.Drawing.Point) method of the UITestControl object. This method will return a Boolean value. So, for example, if you have a WpfButton:
WpfButton mine = new WpfButton(parent);
mine.SearchProperties["id"] = "id";
Point toString;
bool result = mine.TryGetClickablePoint(out toString);
Assert.IsTrue(result, "My Assertion here.");
That has worked more often than not. To handle collapsed or expanded, though, is there some property of the object that changes based on its state? For example, if the class is class="myobject expanded", you could easily assert based onmine.GetProperty("Class").ToString().Contains("expanded"); as a Boolean value.
Try to use GetProperty method:
WpfButton myButton = new WpfButton();
if(myButton.GetProperty("Enabled").Equals(true))
{
... CODE
}
With the latest (October 2010) WPF Ribbon libraries, there exists a menu item to minimize/maximize (or collapse/expand, if you prefer) the ribbon control.
Does anyone know if there's also a way to hook into the events that control this behaviour so that it could be controlled programmatically from separate UI?
Or, better yet, is there a way to get a collapse/expand button to display in the ribbon like the 2010 Office apps do?
You can use the boolean property IsMinimized on the Ribbon class to show/hide the ribbon itself. It is a dependency property, so you can bind to its value to support the scenarios you describe.
As far as I know, the default template does not have a show/hide button, like Office does, but it shouldn't be too hard to modify the template (using Blend) to add one.
If what you need is know when the bar gets minimized (this happens when you double click a tab header) you could hook to the IsMinimizedChanged event, but er.. it is missing.
Hopefully it is a DependencyProperty so you can successfully hook to any DependencyProperty change this way:
DependencyPropertyDescriptor.FromProperty(Ribbon.IsMinimizedProperty, typeof(Ribbon))
.AddValueChanged(ribbon, (o, args) => /* your code here */);
What I wanted to do (and hence got here) is to prevent it from minimizing when double clicking the header so I ended up using this code:
DependencyPropertyDescriptor.FromProperty(Ribbon.IsMinimizedProperty, typeof(Ribbon))
.AddValueChanged(ribbon, (o, args) => ribbon.IsMinimized = false);
Is not so fancy but gets the job done.
Add a toggle button(simple button and set its content to v or ^ depending upon the operation requested) and then you can use ContentControl in button click to fulfill your requirement:
ContentControl contentControl = FindVisualChildataBankyName<ContentControl>(rbnName, "mainItemsPresenterHost");
contentControl.Visibility = System.Windows.Visibility.Collapsed;
Use contentControl.Visibility = System.Windows.Visibility.Visible; in order to maximize the ribbon