|
3 | 3 | xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" |
4 | 4 | xmlns:mauiTabView="clr-namespace:MauiTabView" |
5 | 5 | x:Class="MauiTabView.MainPage" |
6 | | - x:Name="Page"> |
| 6 | + x:Name="Page" |
| 7 | + x:DataType="mauiTabView:MainViewModel"> |
7 | 8 |
|
8 | 9 | <ContentPage.Resources> |
9 | | - <ControlTemplate x:Key="TabControlTemplate"> |
10 | | - <VerticalStackLayout BindingContext="{Binding Source={RelativeSource TemplatedParent}}"> |
11 | | - <Image Source="{Binding Value.Icon}" |
12 | | - WidthRequest="30" |
13 | | - HeightRequest="30" |
14 | | - HorizontalOptions="Center"/> |
15 | | - <Label Text="{Binding Value.Title}" FontSize="12" |
16 | | - HorizontalOptions="Center"/> |
17 | | - </VerticalStackLayout> |
| 10 | + <ControlTemplate x:Key="RadioButtonTemplate"> |
| 11 | + <Border Stroke="#F3F2F1" |
| 12 | + StrokeThickness="2" |
| 13 | + StrokeShape="RoundRectangle 10" |
| 14 | + BackgroundColor="#F3F2F1" |
| 15 | + HeightRequest="90" |
| 16 | + WidthRequest="90" |
| 17 | + HorizontalOptions="Start" |
| 18 | + VerticalOptions="Start"> |
| 19 | + <VisualStateManager.VisualStateGroups> |
| 20 | + <VisualStateGroupList> |
| 21 | + <VisualStateGroup x:Name="CheckedStates"> |
| 22 | + <VisualState x:Name="Checked"> |
| 23 | + <VisualState.Setters> |
| 24 | + <Setter Property="Stroke" |
| 25 | + Value="#FF3300" /> |
| 26 | + <Setter TargetName="check" |
| 27 | + Property="Opacity" |
| 28 | + Value="1" /> |
| 29 | + </VisualState.Setters> |
| 30 | + </VisualState> |
| 31 | + <VisualState x:Name="Unchecked"> |
| 32 | + <VisualState.Setters> |
| 33 | + <Setter Property="BackgroundColor" |
| 34 | + Value="#F3F2F1" /> |
| 35 | + <Setter Property="Stroke" |
| 36 | + Value="#F3F2F1" /> |
| 37 | + <Setter TargetName="check" |
| 38 | + Property="Opacity" |
| 39 | + Value="0" /> |
| 40 | + </VisualState.Setters> |
| 41 | + </VisualState> |
| 42 | + </VisualStateGroup> |
| 43 | + </VisualStateGroupList> |
| 44 | + </VisualStateManager.VisualStateGroups> |
| 45 | + <Grid Margin="4" |
| 46 | + WidthRequest="90"> |
| 47 | + <Grid Margin="0,0,4,0" |
| 48 | + WidthRequest="18" |
| 49 | + HeightRequest="18" |
| 50 | + HorizontalOptions="End" |
| 51 | + VerticalOptions="Start"> |
| 52 | + <Ellipse Stroke="Blue" |
| 53 | + Fill="White" |
| 54 | + WidthRequest="16" |
| 55 | + HeightRequest="16" |
| 56 | + HorizontalOptions="Center" |
| 57 | + VerticalOptions="Center" /> |
| 58 | + <Ellipse x:Name="check" |
| 59 | + Fill="Blue" |
| 60 | + WidthRequest="8" |
| 61 | + HeightRequest="8" |
| 62 | + HorizontalOptions="Center" |
| 63 | + VerticalOptions="Center" /> |
| 64 | + </Grid> |
| 65 | + <ContentPresenter /> |
| 66 | + </Grid> |
| 67 | + </Border> |
18 | 68 | </ControlTemplate> |
19 | 69 |
|
20 | 70 | <DataTemplate x:Key="IndicatorDataTemplate"> |
|
35 | 85 | Spacing="25" |
36 | 86 | Padding="30,0" |
37 | 87 | VerticalOptions="Center"> |
38 | | - |
| 88 | + <!--1--> |
39 | 89 | <Label Text="Carousel + Indicator" |
40 | 90 | FontSize="20" |
41 | 91 | HorizontalOptions="Center"/> |
|
45 | 95 | SelectedIndicatorColor="LightBlue" |
46 | 96 | IndicatorTemplate="{StaticResource IndicatorDataTemplate}"/> |
47 | 97 | </Grid> |
48 | | - <CarouselView ItemsSource="{Binding Tabs}" |
| 98 | + <CarouselView ItemsSource="{Binding Tabs1}" |
49 | 99 | IndicatorView="{x:Reference Indicator}" |
50 | 100 | HorizontalScrollBarVisibility="Never" |
51 | 101 | Loop="False" |
52 | 102 | Position="0"> |
53 | 103 | <CarouselView.ItemTemplate> |
54 | 104 | <DataTemplate x:DataType="mauiTabView:Tab"> |
55 | | - <ContentView Content="{Binding Content}"/> |
| 105 | + <!-- <ContentView Content="{Binding Content}"/> --> |
56 | 106 | </DataTemplate> |
57 | 107 | </CarouselView.ItemTemplate> |
58 | 108 | </CarouselView> |
|
63 | 113 | Y2="0" |
64 | 114 | Stroke="Red" /> |
65 | 115 |
|
| 116 | + <!--2--> |
66 | 117 | <Label Text="RadioButton" |
67 | 118 | FontSize="20" |
68 | 119 | HorizontalOptions="Center"/> |
69 | 120 |
|
70 | 121 | <ScrollView Orientation="Horizontal" |
71 | 122 | HorizontalOptions="Center"> |
72 | | - <HorizontalStackLayout RadioButtonGroup.GroupName="tabs" |
| 123 | + <HorizontalStackLayout BackgroundColor="Red" |
| 124 | + RadioButtonGroup.GroupName="tabs" |
73 | 125 | BindableLayout.ItemsSource="{Binding Tabs2}" |
74 | 126 | RadioButtonGroup.SelectedValue="{Binding SelectedTab}"> |
75 | 127 | <BindableLayout.ItemTemplate> |
76 | | - <DataTemplate x:DataType="Tab"> |
| 128 | + <DataTemplate x:DataType="mauiTabView:Tab"> |
77 | 129 | <RadioButton Value="{Binding }" |
78 | | - ControlTemplate="{StaticResource TabControlTemplate}"> |
| 130 | + ControlTemplate="{StaticResource RadioButtonTemplate}"> |
| 131 | + <RadioButton.Content> |
| 132 | + <VerticalStackLayout> |
| 133 | + <Image Source="{Binding Icon}" |
| 134 | + WidthRequest="30" |
| 135 | + HeightRequest="30" |
| 136 | + HorizontalOptions="Center"/> |
| 137 | + <Label Text="{Binding Title}" FontSize="12" |
| 138 | + HorizontalOptions="Center"/> |
| 139 | + </VerticalStackLayout> |
| 140 | + </RadioButton.Content> |
79 | 141 | </RadioButton> |
80 | 142 | </DataTemplate> |
81 | 143 | </BindableLayout.ItemTemplate> |
82 | 144 | </HorizontalStackLayout> |
83 | 145 | </ScrollView> |
84 | 146 |
|
85 | | - <ContentView Content="{Binding SelectedTab.Content}"/> |
| 147 | + <ContentView Content="{Binding SelectedTab}"/> |
86 | 148 |
|
87 | 149 | <Line X1="0" |
88 | 150 | Y1="0" |
89 | 151 | X2="{Binding Width, Source={x:Reference Page}}" |
90 | 152 | Y2="0" |
91 | 153 | Stroke="Red" /> |
92 | 154 |
|
| 155 | + <!--3--> |
93 | 156 | <Label Text="TabView" |
94 | 157 | FontSize="20" |
95 | 158 | HorizontalOptions="Center"/> |
96 | 159 |
|
97 | 160 | <mauiTabView:TabView> |
98 | 161 | <mauiTabView:TabView.Tabs> |
99 | | - <mauiTabView:Tab Title="Tab1" Icon="cat.png"> |
| 162 | + <mauiTabView:Tab Title="Tab1111" Icon="cat.png"> |
100 | 163 | <mauiTabView:Tab.Content> |
101 | | - <Label Text="Tab1 Label"/> |
| 164 | + <Label Text="Tab1111 Label"/> |
102 | 165 | </mauiTabView:Tab.Content> |
103 | 166 | </mauiTabView:Tab> |
104 | | - <mauiTabView:Tab Title="Tab2" Icon="dog.png"> |
| 167 | + <mauiTabView:Tab Title="Tab2222" Icon="dog.png"> |
105 | 168 | <mauiTabView:Tab.Content> |
106 | | - <Label Text="Tab2 Label"/> |
| 169 | + <Label Text="Tab2222 Label"/> |
107 | 170 | </mauiTabView:Tab.Content> |
108 | 171 | </mauiTabView:Tab> |
109 | 172 | </mauiTabView:TabView.Tabs> |
110 | 173 | </mauiTabView:TabView> |
111 | 174 |
|
112 | | - <Line X1="0" |
113 | | - Y1="0" |
114 | | - X2="{Binding Width, Source={x:Reference Page}}" |
115 | | - Y2="0" |
116 | | - Stroke="Red" /> |
117 | | - |
118 | | - <Label Text="Multiple TabView (using same Tab objects)" |
119 | | - FontSize="20" |
120 | | - HorizontalOptions="Center"/> |
121 | | - |
122 | | - <mauiTabView:TabView Tabs="{Binding Tabs4}"/> |
| 175 | + <mauiTabView:TabView ActiveTabIndex="1"> |
| 176 | + <mauiTabView:TabView.Tabs> |
| 177 | + <mauiTabView:Tab Title="Tab2111" Icon="cat.png"> |
| 178 | + <mauiTabView:Tab.Content> |
| 179 | + <Label Text="Tab2111 Label" /> |
| 180 | + </mauiTabView:Tab.Content> |
| 181 | + </mauiTabView:Tab> |
| 182 | + <mauiTabView:Tab Title="Tab2112" Icon="dog.png"> |
| 183 | + <mauiTabView:Tab.Content> |
| 184 | + <Label Text="Tab2112 Label" /> |
| 185 | + </mauiTabView:Tab.Content> |
| 186 | + </mauiTabView:Tab> |
| 187 | + </mauiTabView:TabView.Tabs> |
| 188 | + </mauiTabView:TabView> |
123 | 189 |
|
124 | 190 | <Line X1="0" |
125 | 191 | Y1="0" |
126 | 192 | X2="{Binding Width, Source={x:Reference Page}}" |
127 | 193 | Y2="0" |
128 | 194 | Stroke="Red" /> |
129 | 195 |
|
130 | | - <Label Text="TabView Binding" |
| 196 | + <!--4--> |
| 197 | + <Label Text="Multiple TabView with Binding (using same Tab objects)" |
131 | 198 | FontSize="20" |
132 | 199 | HorizontalOptions="Center"/> |
133 | 200 |
|
134 | 201 | <mauiTabView:TabView Tabs="{Binding Tabs3}"/> |
| 202 | + <mauiTabView:TabView Tabs="{Binding Tabs3}"/> |
135 | 203 |
|
136 | 204 | </VerticalStackLayout> |
137 | 205 | </ScrollView> |
|
0 commit comments