The GIS Framework provides attributes for basic rendering of common UI elements. These can be used in the viewmodel as an alternative to constructing a dialog's layout in XAML. This can be especially useful to speed up
Developing New Components. The following attributes are currently supported:
General Attributes
Name | Description | Named Parameters |
---|
DisplayNameAttribute | Defines the text on the field label | Name (string) |
ToolTipTextAttribute | Defines the tooltip text for the field | Text (string) |
ResizableAttribute | Allows the window to be resized by the user |
HiddenAttribute | Prevents the field from being displayed |
AutoResizeAttribute | Allows the generated field to resize vertically and fill available space when the user resizes the host dialog |
Field-based Attributes
Name | Description | Named Parameters |
---|
TextAttribute | Render field as TextBox or PasswordBox (Secret=true) | Secret (bool) |
DropdownAttribute | Render field as ComboBox | optionSource (string=Field|Property|Method|Enumeration|None) |
CheckAttribute | Render field as checkbox |
SwitchButtonAttribute | Render field as SwitchButton (iPhone-style on/off switch) |
DateAttribute | Render field as DatePicker |
NumericUpDownAttribute | Render field as NumericUpDown | Minimum (int default=0), Maximum (int default=100), DecimalPlaces (int default=0), Increment (int default=1) |
LabelAttribute | Render field as read-only TextBlock |
ProgressAttribute | Render field as ProgressBar | Minimum (int default=0), Maximum (int default=100) |
SliderAttribute | Render field as Slider | Minimum (int default=0), Maximum (int default=100) |
ListAttribute | Render field as ListBox | displayMemberPath (string) |
TableAttribute | Render field as DataGrid |
ChartAttribute | Render field as Chart | ChartType (ChartTypeEnum=Line|Column|Bar|Pie), IndependentAxisName (string), DependentAxisName (string) |
Action-based Attributes
Name | Description | Named Parameters |
---|
ActionAttribute | Render method as Button |
Example
[DisplayName("Dialog Created From Attributes Example")]
public class MyComponentSettingsViewModel : SettingsViewModel
{
private static MyComponentSettingsViewModel _viewModel = new MyComponentSettingsViewModel();
private MyComponentSettingsViewModel()
{
DialogServiceArgs.Id = "mycomponentsettingsviewmodel";
DialogServiceArgs.Title = "My Component Settings";
}
[Hidden]
public static MyComponentSettingsViewModel Instance
{
get { return _viewModel; }
}
[Label]
[DisplayName("")]
public string TextMessage
{
get
{
return "This example uses the LayoutManager to build a view based on\n" +
"a viewmodel with custom attributes that describe how the\n" +
"viewmodel should be rendered. Actions can also be used via\n" +
"the ActionAttribute applied to a method.";
}
}
[SwitchButton]
[DisplayName("Switch Button")]
[ToolTipText("Sets a boolean property and persists it to Silverlight Isolated Storage")]
public bool MyBoolProperty
{
get { return StateManager.GetProperty<bool>("MyBoolProperty"); }
set
{
StateManager.SetProperty("MyBoolProperty", value);
NotifyOfPropertyChange(() => MyBoolProperty);
}
}
[ActionAttribute]
[DisplayName("Do Something Now")]
public void DoSomething()
{
MessageBox.Show("Can invoke an action here.");
}
}
See Also