Right to Left in UWP based on condition? - c#

I am working on Windows 10 App and in my app, I get languages from the server and user can select any language from that. Now if the user selects Arabic, it works in RighttoLeft so I want to change it for all UI controls. Can someone suggest the easiest way to do that?
I am aware that we can use FlowDirection attribute for it. But there are many controls in my app and for each and every control, it will be difficult to change FlowDirection.

Related

How to get which button is which in a Yes/No/Cancel dialog using UI Automation?

In the proprietary third-party application my program has to communicate with, there is a situation where an operation I have to invoke displays a system dialog with Yes/No/Cancel buttons. I now need to push the "Yes" button. There is no vendor-side function to tell the application to do the operation that starts when I push "Yes", so I have to use UI automation.
Where I am stuck with is the localization of the Windows standard dialogs. The caption of the "Yes" button is different depending on the language Windows is used in, and the order might also be different in languages which are written from right to left.
Since we are currently only using German and English versions of Windows where this program is used, I currently just click the first element in the subtree of the window that supports the InvokePattern which is always "Yes" in these language versions, and the program is used only in-house. But I don't like this, I want a robust way to determine which button is which. Is this possible with UI automation?
Best practice is to use the AutomationID property to uniquely identify a button. Don't use the Runtime ID, as that's not guaranteed to be unique across invocations.
Well if you are only targeting English and German, you can just look for a control with a caption/text property of "Yes" (for English). In German environments, look for the German equivalent of yes which you should know at coding-time.
This is best practice I used in privious project for UI automation in localized software:
Use AutomationId(UIA)/ControlId(MSAA) if possible.
Locate corresponding resource file and load string from it. Then search it in UI. Hard code localized string in test code is bad idea. You can't grantee that
text is translated correctly even for Windows
text is already translated in specific language when you expand your scope.
text is translated consistently everywhere.
Simulate keyboard {tab} and {space} to click a button.
Use control sequence as you're currently doing, but nobody can grantee that button with index 0 is in the leftmost.
Use absolute pixel/position. Sometimes button are drawn as picture.

How to scroll ListBoxes naturally on the touch-screens in WPF application?

I am developing WPF application which will be executing on the 21-inch touch-screen.
Along with ListBoxes in my application I have vertical scroll-bars for each of them. What I want is to get rid of those scroll-bars and just allow user to scroll naturally by touching lists itself. How can I achieve that? Is there out-of-the-box support for that in Windows 7 and .NET 4.0?
I know this is an old question, but it came up for me first in Google. So just in case someone else comes here, the answer to this is in this SO question. Simply set the PanningMode, PanningDeceleration, and PanningRatio for the ScrollViewer.
It worked for me on a ComboBox as well.
<ComboBox ... ScrollViewer.PanningMode="VerticalOnly" />
Have a look at this similar question
Although WPF supports touch events out of the box WPF is very limited for this kind of scenario.
I am hoping for 3rd parties (or even Microsoft) to add the Windows 8/Metro touch experience to WPF

How to change controls on a Windows form without changing the form itself

What I am trying to remember is the name of a windows form control which allows with an ID change allows programmer to move between its states, which are different panels with different controls on them. There is a control that does exactly this - but I can't remember its name at all. Do you know anything similar to this in C#?
edit: basically, I have a windows form. It has a panel. I want to, by changing panel's a specific property, I want to switch between its states, every state containing another set of windows form controls. I cannot, however, remember the name of this control. Any ideas? Sorry if my first wording is confusing.
It sounds like you mean something like a wizard? In asp.net webforms has a wizard control buy afaik the closest in windows forms is TabControl. But no matter; it is trivial to simply hide and show some Panel controls. It can be trickier to use the designer, of course - but you can lay them out next to each other and move then at runtime as needed.
Looks like there are a few wizards available for WinForms too
https://stackoverflow.com/questions/195255/best-wizard-control-for-net-windows-forms
http://www.codeproject.com/KB/cs/WizardDemo.aspx
And, well, plenty of others

Make WPF Listview adhere to the Windows theme

I am an experienced coder who is trying to learn C# and WPF. Now, I am a bit of a stickler for detail, and I want to make sure my applications blend in with the rest of the user interface. However, I cannot seem to get this done using a ListView. My setup is simple - add a ListView to my window, bind to an ObservableCollection of my choice, and run the application.
The result is that the items pop up just fine (be it without meaningful contents). However, the selection rectangle on a ListView is always the dark blue that throws me back to the pre-XP days as opposed to the neater themed selection you have using the default Windows 7 visual style. To see that kind of selection in action, just select a file in explorer, or for another example look in the Programs and Features in the Control Panel. That looks nice and slick.
How can I get WPF to properly theme my ListView depending on my user settings? I don't want to reinvent the entire selection code and add tons of styling and doodahs like that - I want a plain Windows application that looks okay. The button works fine, textboxes work fine, comboboxes look fine, etc. It's just the ListView that looks totally crap.
Edit: I have no problems using another (very, very preferably not a thirdparty) control if required, but I do want a list of items that looks native and I approach a layout similar to the Tiles option in Explorer for each selected item (icon, desc, extra line of info). Vertical scrolling only is what I need.
If you use a ListView with ListView.View set to a GridView then you get a pretty similar look as Windows 7 explorer. (Atleast in my opinion, or is this the look you're talking about?). It also follows the active theme
Example 1. ListView with GridView to the right. Selection active
Example 2. ListView with GridView to the right. Selection inactive
Example 3. Using High Contrast Theme #2

Windows mobile UI: Is a messagebox appropriate to display information?

I have a list of items in a listview and when the user double-clicks an item, I display a messagebox with the contact's name and address.
My boss doesn;t like it because he thinks this violate some UI design principle for Windows Mobile devices. I can't find anything that prohibits this. He is thinking that it has something to do with the device not being able to go into power-saving mode when a message-box is displayed.
Is he right? Can you suggest an alternative (he doesn;t have an alternative except he doesn;t like what i have)
C#, Windows Mobile 6.0, WinForms
Windows Mobile 6 uses MessageBox all the time. It is probably better than rolling your own solution because you'll automatically benefit from updates in WM6.5 which a custom solution wouldn't.
The device has no problem going into power-saving mode while a message box is displayed. Other options available to you include using a tabbed view and switching to another tab to display details, or creating and displaying a new form to display details.

Categories

Resources