Hi everyone,
I'm starting with Xamarin and I didn't find how to change a source of image in controltemplate. I want to change the image when the Wi-Fi state change.
I didn't use the MVVM model.
I attach my code of my controltemplate in App.xaml.
<ControlTemplate x:Key="State"> <Grid ColumnSpacing="0"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="11*"/> </Grid.ColumnDefinitions>
<BoxView Grid.Column="0" Style="{DynamicResource boxviewStyle}"/>
<ContentPresenter Grid.Column="1" />
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button x:Name="ButtonHome" Grid.Column="0" Grid.Row="0" Style="{DynamicResource buttonStyle}" Image="home_48x46.png" Clicked="onClickedButtonHome"/>
<Label x:Name="LabelBattery" Grid.Column="0" Grid.Row="1" Style="{DynamicResource labelStyle}" TextColor="White" Text="100 %" VerticalOptions="Center" HorizontalOptions="Start" Margin="5"/>
<Image x:Name="Battery" Grid.Column="0" Grid.Row="1" Source="battery_icon_100_40px.png" VerticalOptions="Center" HorizontalOptions="End" Margin="5"/>
<Label x:Name="LabelTime" Grid.Column="0" Grid.Row="2" Style="{DynamicResource labelStyle}" HorizontalOptions="Center" Text="08:35"/>
<Button x:Name="ButtonGPS" Grid.Column="0" Grid.Row="3" Style="{DynamicResource buttonStyle}" Image="gps_icon_pos_70px.png" Clicked="onClickedButtonGPS"/>
<Image x:Name="ImageWIFI" Grid.Column="0" Grid.Row="4" Source="wifi_off_70px.png" HorizontalOptions="Center"/>
<Button x:Name="ButtonMore" Grid.Column="0" Grid.Row="6" Style="{DynamicResource buttonStyle}" Image="trois_points_70px.png" Clicked="onClickedButtonMore"/>
</Grid>
</Grid>
</ControlTemplate>`
Thank you very much,