# RatingControl

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls/struct-ratingcontrol/

**struct** · [`ferroui-controls`](/docs/0.5.0/api/ferroui-controls/) · v0.5.0

```rust
struct RatingControl
```

A control to rate with stars (WinUI's `RatingControl`): a value from 1 to `MaxRating`, or -1
while it is not set, a placeholder value (a community rating) shown while it is not set, and a
caption.

The items are drawn twice, in the background stack panel in the unset state and in the
foreground stack panel clipped to the value, from the glyphs of a [`RatingItemFontInfo`](/docs/0.5.0/api/ferroui-controls/struct-ratingitemfontinfo/) (the
stars E735 and E734 of the symbol font by default, in the font of the control) or the images of
a [`RatingItemImageInfo`](/docs/0.5.0/api/ferroui-controls/struct-ratingitemimageinfo/). A click or a tap sets the rating under the pointer, and clears it
when it is the rating (with `IsClearEnabled`); the arrow keys, Home and End change it. Only the
changes of the user raise `ValueChanged`.

The template is the control theme of the WinUI theme (`Controls/RatingControl.xaml`, from
WinUI's `RatingControl.xaml`), with WinUI's parts `RatingBackgroundStackPanel` and
`RatingForegroundStackPanel`; the items take their size from the `FontSize` of the stack
panels (`RatingControlFontSizeForRendering`) and their brushes from the theme. The control
sets WinUI's visual states (CommonStates) as the pseudo-classes `:placeholder`,
`:pointeroverplaceholder`, `:pointeroverunselected`, `:set` and `:pointeroverset` (Disabled is
`:disabled`). The Fluent and Simple themes have no template for it
(docs/porting/winui-controls.md, section 5.1).

Missing (docs/porting/winui-controls.md, Input): the composition animations of the scale of the
items (the scale is set when the pointer moves), and the focus engagement of the gamepad
(`IsFocusEngagementEnabled`, GamepadA and GamepadB).

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L77)

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`caption_property`](#function-caption_property)
- [`initial_set_value_property`](#function-initial_set_value_property)
- [`is_clear_enabled_property`](#function-is_clear_enabled_property)
- [`is_read_only_property`](#function-is_read_only_property)
- [`max_rating_property`](#function-max_rating_property)
- [`placeholder_value_property`](#function-placeholder_value_property)
- [`item_info_property`](#function-item_info_property)
- [`value_property`](#function-value_property)
- [`construct`](#function-construct)
- [`new`](#function-new)
- [`caption`](#function-caption)
- [`set_caption`](#function-set_caption)
- [`initial_set_value`](#function-initial_set_value)
- [`set_initial_set_value`](#function-set_initial_set_value)
- [`is_clear_enabled`](#function-is_clear_enabled)
- [`set_is_clear_enabled`](#function-set_is_clear_enabled)
- [`is_read_only`](#function-is_read_only)
- [`set_is_read_only`](#function-set_is_read_only)
- [`max_rating`](#function-max_rating)
- [`set_max_rating`](#function-set_max_rating)
- [`placeholder_value`](#function-placeholder_value)
- [`set_placeholder_value`](#function-set_placeholder_value)
- [`item_info`](#function-item_info)
- [`set_item_info`](#function-set_item_info)
- [`value`](#function-value)
- [`set_rating_value`](#function-set_rating_value)
- [`value_changed`](#function-value_changed)

<a id="assoc_const-type"></a>

### TYPE

```rust
const TYPE: &'static $crate::TypeInfo
```

The runtime type of this class.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L96)

<a id="function-to_ref"></a>

### to_ref

```rust
fn to_ref(self: &Self) -> $crate::Ref<RatingControl>
```

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L96)

<a id="function-caption_property"></a>

### caption_property

```rust
fn caption_property() -> &'static StyledProperty<String>
```

Defines the `Caption` property: the text beside the items.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L316)

<a id="function-initial_set_value_property"></a>

### initial_set_value_property

```rust
fn initial_set_value_property() -> &'static StyledProperty<i32>
```

Defines the `InitialSetValue` property: the rating the keys start from while the rating
is not set. 1 by default.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L316)

<a id="function-is_clear_enabled_property"></a>

### is_clear_enabled_property

```rust
fn is_clear_enabled_property() -> &'static StyledProperty<bool>
```

Defines the `IsClearEnabled` property: whether choosing the rating again clears it.
`true` by default.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L316)

<a id="function-is_read_only_property"></a>

### is_read_only_property

```rust
fn is_read_only_property() -> &'static StyledProperty<bool>
```

Defines the `IsReadOnly` property: whether the user cannot change the rating.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L316)

<a id="function-max_rating_property"></a>

### max_rating_property

```rust
fn max_rating_property() -> &'static StyledProperty<i32>
```

Defines the `MaxRating` property: the number of items. 5 by default; a value less than 1
is 1.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L316)

<a id="function-placeholder_value_property"></a>

### placeholder_value_property

```rust
fn placeholder_value_property() -> &'static StyledProperty<f64>
```

Defines the `PlaceholderValue` property: the rating shown while the rating is not set
(a community rating), -1 for none (the default). From 0 to `MaxRating`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L316)

<a id="function-item_info_property"></a>

### item_info_property

```rust
fn item_info_property() -> &'static StyledProperty<Option<Ref<RatingItemInfo>>>
```

Defines the `ItemInfo` property: the glyphs or the images of the items.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L316)

<a id="function-value_property"></a>

### value_property

```rust
fn value_property() -> &'static StyledProperty<f64>
```

Defines the `Value` property: the rating, from 1 to `MaxRating`, or -1 while it is not
set (the default).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L316)

<a id="function-construct"></a>

### construct

```rust
fn construct() -> Self
```

Creates the class data; see `ferroui_base::FerroObject::construct`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L391)

<a id="function-new"></a>

### new

```rust
fn new() -> Ref<Self>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L410)

<a id="function-caption"></a>

### caption

```rust
fn caption(self: &Self) -> String
```

Gets the text beside the items.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L415)

<a id="function-set_caption"></a>

### set_caption

```rust
fn set_caption(self: &Self, value: impl Into<String>)
```

Sets the text beside the items.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L420)

<a id="function-initial_set_value"></a>

### initial_set_value

```rust
fn initial_set_value(self: &Self) -> i32
```

Gets the rating the keys start from while the rating is not set.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L425)

<a id="function-set_initial_set_value"></a>

### set_initial_set_value

```rust
fn set_initial_set_value(self: &Self, value: i32)
```

Sets the rating the keys start from while the rating is not set.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L430)

<a id="function-is_clear_enabled"></a>

### is_clear_enabled

```rust
fn is_clear_enabled(self: &Self) -> bool
```

Gets whether choosing the rating again clears it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L435)

<a id="function-set_is_clear_enabled"></a>

### set_is_clear_enabled

```rust
fn set_is_clear_enabled(self: &Self, value: bool)
```

Sets whether choosing the rating again clears it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L440)

<a id="function-is_read_only"></a>

### is_read_only

```rust
fn is_read_only(self: &Self) -> bool
```

Gets whether the user cannot change the rating.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L445)

<a id="function-set_is_read_only"></a>

### set_is_read_only

```rust
fn set_is_read_only(self: &Self, value: bool)
```

Sets whether the user cannot change the rating.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L450)

<a id="function-max_rating"></a>

### max_rating

```rust
fn max_rating(self: &Self) -> i32
```

Gets the number of items.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L455)

<a id="function-set_max_rating"></a>

### set_max_rating

```rust
fn set_max_rating(self: &Self, value: i32)
```

Sets the number of items.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L460)

<a id="function-placeholder_value"></a>

### placeholder_value

```rust
fn placeholder_value(self: &Self) -> f64
```

Gets the rating shown while the rating is not set.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L465)

<a id="function-set_placeholder_value"></a>

### set_placeholder_value

```rust
fn set_placeholder_value(self: &Self, value: f64)
```

Sets the rating shown while the rating is not set.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L470)

<a id="function-item_info"></a>

### item_info

```rust
fn item_info(self: &Self) -> Option<Ref<RatingItemInfo>>
```

Gets the glyphs or the images of the items.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L475)

<a id="function-set_item_info"></a>

### set_item_info

```rust
fn set_item_info(self: &Self, value: Option<Ref<RatingItemInfo>>)
```

Sets the glyphs or the images of the items.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L480)

<a id="function-value"></a>

### value

```rust
fn value(self: &Self) -> f64
```

Gets the rating: -1 while it is not set.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L485)

<a id="function-set_rating_value"></a>

### set_rating_value

```rust
fn set_rating_value(self: &Self, value: f64)
```

Sets the rating. A change made here does not raise `ValueChanged`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L490)

<a id="function-value_changed"></a>

### value_changed

```rust
fn value_changed(self: &Self, handler: impl Fn(&RatingControl) -> () + 'static) -> Subscription
```

Adds a handler of the `ValueChanged` event, raised for the changes of the user only.

Dropping the returned guard removes the handler; `Subscription::detach` keeps it
for the life of the control.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/rating_control.rs#L498)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`TemplatedControlImplExt`](/docs/0.5.0/api/ferroui-controls/primitives/trait-templatedcontrolimplext/)
- [`ControlImplExt`](/docs/0.5.0/api/ferroui-controls/trait-controlimplext/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- [`InputElementImplExt`](/docs/0.5.0/api/ferroui-base/input/trait-inputelementimplext/)
- [`InteractiveImplExt`](/docs/0.5.0/api/ferroui-base/interactivity/trait-interactiveimplext/)
- [`LayoutableImplExt`](/docs/0.5.0/api/ferroui-base/layout/trait-layoutableimplext/)
- [`FerroObjectImplExt`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimplext/)
- [`StyledElementImplExt`](/docs/0.5.0/api/ferroui-base/trait-styledelementimplext/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- [`VisualImplExt`](/docs/0.5.0/api/ferroui-base/trait-visualimplext/)
- `ErasedDestructor`
- `IntoEither`
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<RatingControl>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`StaticType`](/docs/0.5.0/api/ferroui-base/trait-statictype/)
- [`ObjectType`](/docs/0.5.0/api/ferroui-base/trait-objecttype/)
- [`Subclassable<T>`](/docs/0.5.0/api/ferroui-base/trait-subclassable/)
- [`DefaultConstructible`](/docs/0.5.0/api/ferroui-base/trait-defaultconstructible/)
- [`StyledElementImpl`](/docs/0.5.0/api/ferroui-base/trait-styledelementimpl/)
- [`VisualImpl`](/docs/0.5.0/api/ferroui-base/trait-visualimpl/)
- [`LayoutableImpl`](/docs/0.5.0/api/ferroui-base/layout/trait-layoutableimpl/)
- [`InteractiveImpl`](/docs/0.5.0/api/ferroui-base/interactivity/trait-interactiveimpl/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)
- [`ControlImpl`](/docs/0.5.0/api/ferroui-controls/trait-controlimpl/)
- [`TemplatedControlImpl`](/docs/0.5.0/api/ferroui-controls/primitives/trait-templatedcontrolimpl/)
- [`InputElementImpl`](/docs/0.5.0/api/ferroui-base/input/trait-inputelementimpl/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
