Working With Properties - nicklikescoffee/UltimateUiPlugin GitHub Wiki
In Ultimate UI you can get and set properties for several Controls.
Naming Your Controls
In order for Ultimate UI to be able to manipulate your Controls, you must name them. that means adding the property x:Name to your Control. For example:
<TextBox x:Name="nameTextBox"/>
You only need to name Controls that you wish to manipulate. If you have no plans on changing the property of a Control - or using Events with it - then you can omit the x:Name property.
Using UI Set Property
In the XAML Commands section, you will find a command named UI Set Property. This is a special command because it will work on any standard WPF Control.
That means that you can set the Enabled, Visibility, Width, Height, and so on (there are many more properties) on any control you wish by using this one command.
This also means that you won't be finding all of these properties on each specific command (for a Control). So if you need to change a basic property and you do not find it in the specific command for the Control - then check UI Set Property.
Likewise, you can find UI Get Property under the XAML Functions section. This also works on any standard WPF Control and has many properties that you can get.
Specific Control Properties
You will often need to set properties of a specific Control. You can find all the current supported Controls under the Set Property Commands and Get Property Functions sections.
In order to quickly find the right command or function to use, simply type the name of the Control - such as "textbox" in the search.
Let's look at an example of how to set and get a property from a TextBox Control. Paste and run the following code:
plugin command("UltimateUI.dll", "UI Load XAML", "<StackPanel Orientation=\"Horizontal\" Height=\"30\">
<TextBlock Text=\"Name\"/>
<TextBox x:Name=\"nameTextBox\" Width=\"100\"/>
</StackPanel>", "True", "False", "False", "BaseDark", "Green")
plugin command("UltimateUI.dll", "UI Set TextBox Property", "Text", "nameTextBox", "type your name here")
alert($plugin function("UltimateUI.dll", "$UI Get TextBox Property", "Text", "nameTextBox"))
Exceptions
Knowing exactly what to type for the value of a property isn't always obvious. For example, you may wish to set the Visibility of a property. How do you know what to put for the value of the property?
In cases like this you can go ahead and just type anything. And when you make a mistake Ultimate UI will give you an error message. Do not close this message immediately! Ultimate UI will tell you exactly what it needs in order to set the property correctly.
Consider the following code which will throw an error:
plugin command("UltimateUI.dll", "UI Load XAML", "<StackPanel Orientation=\"Horizontal\" Height=\"30\">
<TextBlock Text=\"Name\"/>
<TextBox x:Name=\"nameTextBox\" Width=\"100\"/>
</StackPanel>", "True", "False", "False", "BaseDark", "Green")
plugin command("UltimateUI.dll", "UI Set Property", "Visibility", "nameTextBox", "True")
As you can see Ultimate UI will tell you that you need to use a certain function in order to correctly set this property. This is a property function that will give you a list of options to choose from. We will talk about property functions in the next section but for now, paste the following code and you will see now that the error is gone.
plugin command("UltimateUI.dll", "UI Load XAML", "<StackPanel Orientation=\"Horizontal\" Height=\"30\">
<TextBlock Text=\"Name\"/>
<TextBox x:Name=\"nameTextBox\" Width=\"100\"/>
</StackPanel>", "True", "False", "False", "BaseDark", "Green")
plugin command("UltimateUI.dll", "UI Set Property", "Visibility", "nameTextBox", $plugin function("UltimateUI.dll", "$UI Visibility", "Hidden"))
Property Functions
Property functions will help you correctly set certain properties. As noted in the Exceptions section - sometimes Ultimate UI will tell you to use a property function in order to set a certain property.
Property functions will give you a list of valid options to choose from making it much easier to set properties where it may be difficult to know exactly what to fill in for the value.
You can find these property functions under the Property Functions section.
UI Font Family
UI Font Family will show you all of the fonts you have installed on your machine. This does not necessarily mean that your users will have these fonts installed. So it's a good idea to choose a font that you think your users will have installed.