How to add android attributes like android:id on Xamarin Forms(XAML)? - xamarin.forms

I've already tried setting android attributes like contentdescription by creating a custom element and setting the attribute on the renderer using the control.
Control.ContentDescription = ((MyEntry)e.NewElement).ContentDescription;
Is there a way to do it on the XAML rather than custom renderer?
Another, how can I set the android:id attribute? I've tried it change it on custom render but I think it's not working.
Sidenote: I'm using a RealWear device which can generats a script which has the UI elements of the page. The UI elements will contain the id attribute if it exists.

Hello and welcome to StackOverflow.
you can't add Android descriptions to xamarin forms elements.
Xamarin forms abstracts the ui to a non-native format (xaml) and converts the abstract definition of an element to a native one. However this happens "under the hood" and therefore you don't have direct access to that from xamarin.forms.
What you could do is, if you really need an element with a set id, you can either find a way to hack in your id using a custom renderer or you create and embed native elements.
For the latter please see the following microsoft article, which is a bit too much to include within this answer: https://msdn.microsoft.com/en-us/magazine/mt790186.aspx

Related

What is the proper way to create control in Xamarin Form PCL?

What is the proper way to create control in Xamarin Form PCL?
In my class library I have "control" class not derived from any View, just a layout with some labels, scrollviews, logic etc.
I am using it in my pages in the same PLC in several places.
My question is - what is the proper way to wrap this "control" and use it in PLC pages?
I ended up having this control class to expose its root layout where I add all the child elements and subsequently add this layout to the children of page layout. This makes this class to be some sort of a builder of a part of UI of a page.
It looks like that using "View" as a base class requires me to add custom renderers to Android and iOS projects
which I don't need to do - all my UI functionality fits into PCL withot the need for any custom work.
I have a feeling that I am not doing it the right way.
Advise and/or link to the documentation on how to properly do it will be greatly appreciated.
It seems to me that you're actually hurting yourself by not wanting to use a View as a base class. I commonly use ContentView as a base class to create my own controls and it works great without the need for a custom renderer since ContentView already has its own renderers in iOS and Android. Something like this should do the trick.
public class MyContentView : ContentView
{
private Layout createLayout();
public MyContentView()
{
Content = createLayout();
}
}

Impossible make a input or AtomTextEditor with React

I'm making a plugin that gets the actual panel or text selection and runs a command on the cli with that value and some params that the user adds in a input.
The idea is to have a similar view than find-and-replace package, but from the first beginning I wasn't able to use space-pane-views for a error on jQuery.
So I decided to make it with React and as far as I was making everything was okayish, but I found 2 big problems.
First I understand what's the View of space-pan and all the ShadowDOM that uses, I feel that is not compatible with React at all, is some kind of big Model that gets data from the dom and from some methods.
So I created a <input /> and I figuret out that you can't interact as normal as a website with that input, doesn't have the hability of delete normally the text and you can't use the atom-text-editor styles into it.
in another hand I try to create a Custom Web Component with React like:
<atom-text-editor
{...this.props}
mini
tabindex='-1'
class={`${this.props.className}`}
data-grammar='text plain null-grammar'
data-encoding='utf8'
/>
and it works with inheriting the styles, but I can't access to the content of the Shadow DOM, neither add eventHandlers like onChange (onKeyPress works btw), this is basically a problem more than React that Atom, but is as far as I went in the intention to create a View in Atom.
Another option could be add draft-js from Fb, but it's a crazy idea for create a simple input.
Any idea to solve one of both problems?
Thanks!
If you add a normal input in React with className='native-key-bindings' the input contains the nativew key bindings, and you can attach the eventHandlers there.

Change WF4 ActivityDesigner theme

I want to change my rehosted activities look to:
Already tried ActivityDesignerTheme
Need to do it without using WorkflowViewElement because I don't want to lose it's behaviors (breakpoint, expanding).
If it's not possible, is there a way to change ActivityDesigner header background color?
#Will
I was annoyed too by the default behavior of the ActivityDesigner header when editing the DisplayName (especially the part where it positions the caret at the beginning of the string). I used Reflector to peek (System.Activities.Presentation.dll) at the implementation and I noticed that some of this behavior is defined in OnApplyTemplate. By just overriding this method in my custom designer class and NOT calling base.OnApplyTemplate(), I was able to make the DisplayName read only in the header (in my case that was all I needed, but I think one can play with some custom event handlers in there and tweak the behavior).
#Davi Fiamenghi
Digging around some more with Reflector in the same assembly, I found the controls used in OnApplyTemplate defined under system/activities/presentation/workflowelementdesignerdefaulttemplate.baml (System.Activities.Presentation.g.resources). That seems to be the default control template used for ActivityDesigner (<ControlTemplate x:Key="WorkflowElementDesignerDefaultTemplate" x:Uid="ControlTemplate_1" ControlTemplate.TargetType="{x:Type swd:ActivityDesigner}">). I guess one way to change the header color would be to try to "re-create" this template in your application and set it explicitly in your custom activity designer. Of course it's more involved than just copying it, since it appears to be referencing other resources defined in that assembly.
Hope this helps.

Now able to get Id property for flex components

I am not able to get the Id property for flex components in my flex application(swf file) using Test Object Inspector in Rft Tool.
How can i get them?
You can't. Flex mxml component ids are only used as a hash within the containing parent. They're only used for referencing objects and are discarded at compile time.
If you have an id property for your flex component then there are a couple of ways to find out the id property of your desired control.
Make sure you have embeded your .swf file inside an html wrapper(as suggetsed by RFT) and displaying it in an enabled IE browser.
Hover over the component, say a button(and you should see automation name as well as id value).
Else you can do a simple script call to get the id of desired component:
System.out.println(desired_object().getProperty(".id"));

How to specify in QTP's Object Repository, that I want to find Web Button object by title

I have rich web application with a lot of dynamic stuff (used ExtJS 3.0). I want to find Web Button using HP QuickTest Pro 10. This web button have only one property , that can uniquely identify it: title. But if I define that object in Object Repository with Description Property Title= it doesn't find it.
Please, advise me what can I do in that situation? I've tried to use object.title=Some value as well, but it doesn't helped.
Thanks!
Title is a DOM property not a QTP property, you can use DOM properties for identification by appending attribute/ to the property name.
Try adding a new property "attribute/title" to the button class, and make that an identification property in the object identification configuration.
The "attribute/" prefix allows you to use any attribute that you can access via the Object property.

Resources