-
Notifications
You must be signed in to change notification settings - Fork 12
ContentControl
Håvard Moås edited this page Jun 4, 2020
·
5 revisions
Namespace: DIPS.Xamarin.UI.Controls.Content
A ContentControl
is a Control to show different DataTemplates based on the current BindingContext
of the ContentControl.
👉 To get started, make sure you have followed the getting started steps
Setup datatemplates and create a class inheriting from DataTemplateSelector
:
<DataTemplate x:Key="vm1Template">
<Frame BackgroundColor="WhiteSmoke" HasShadow="False">
<Label Text="{Binding LuckyNumber}" />
</Frame>
</DataTemplate>
<DataTemplate x:Key="vm2Template">
<Frame BackgroundColor="#343434" HasShadow="False">
<Label Text="{Binding Title}" TextColor="WhiteSmoke" />
</Frame>
</DataTemplate>
<ViewModel:ContentControlTemplateSelector
x:Key="templateSelector"
VM1Template="{StaticResource vm1Template}"
VM2Template="{StaticResource vm2Template}" />
Use the ContentControl with the templateSelector:
<dxui:ContentControl BindingContext="{Binding Content}" TemplateSelector="{StaticResource templateSelector}" />
Use the ContentControl with templateSelector and SelectorItem:
<content:ContentControl
Grid.Row="1"
BindingContext="{Binding VM1}"
SelectorItem="{Binding SwapTemplate}"
TemplateSelector="{StaticResource boolSelector}" />
Reminder: As BindingContext changes, SelectorItem will be bound to a new ViewModel.
Property | Explanation | Remarks | default value |
---|---|---|---|
TemplateSelector |
The DataTemplateSelector to be used when BindingContext is changed | null | |
SelectorItem |
The item to swap Content based on. This is sent to the TemplateSelector. If you don't set this, BindingContext is sent to TemplateSelector. | null |
- ContentControl
- DataTemplateSelectors
- Date- and TimePicker
- Modality
- Contextual Menus
- RadioButton
- TrendGraph
- Tag
- Toast