Click or drag to resize
DigitalRuneFAQ
My UIScreen hides graphics behind it. How can I make a UIScreen transparent?

The UIScreen class has a Background property which defines the color used to fill the background of the whole screen. You can set this color to transparent, for example:

C#
myScreen.Background = new Color(0, 0, 0, 0);
How can I scroll a TextBox using code?

Just move the caret. The TextBox will scroll automatically to make the caret visible. For example, to scroll to the end:

C#
myTextBox.CaretIndex = myTextBox.Text.Length;

A more complicated way is to get the scroll bar and manipulate it: After the text box was loaded (e.g. shown on the screen), get the contained scroll bar:

C#
scrollBar = myTextBox.GetDescendants(false)  // GetDescendants() is an extension method of the UIHelper class.
                     .OfType<ScrollBar>()
                     .First();
scrollBar.Value = scrollBar.Maximum;
Window dragging does not work if window is not left/top aligned

This is a limitation of the Window drag implementation. It only works for the default left/top alignment. The current system supports following window positioning scenarios:

How can I programmatically raise the Button.Click event?

If you want to raise the Click event of a button from "outside" the button code, you can get the IsClicked property and set it to true:

C#
var isClickedProperty = myButton.Properties.Get<bool>(ButtonBase.IsClickedPropertyId);
isClickedProperty.Value = true;

When the IsClicked property changes to true, it triggers the Click event. You could also trigger the Click event directly:

C#
var clickEvent = myButton.Events.Get<EventArgs>(Button.ClickEventId);
clickEvent.Raise();
How can I export/import GUI controls?

You can use the LayoutSerializer class to load controls from an XML file. The class does not support serialization into an XML file yet. You have to create this part yourself. Use .NET reflection to enumerate the class properties of the controls and create an XML that is compatible to the XML required by the LayoutSerializer.

References:

  • An example XML file is contained in the ControlsSample of the DgiitalRune Samples.
  • If you have access to the Premium Downloads, check out the source code of the LayoutSerializer class.

Some more tips:

  • You only need to write the properties into the XML that are read/write-able. (Do not write read-only properties.)
  • Do not write properties that have their default value.