Pārlūkot izejas kodu

Button in RouteSelectPage aangepast

guusvdongen 10 gadi atpakaļ
vecāks
revīzija
f0e7dbaaaa

BIN
Breda-Tour/Assets/UitklapIcon1.png


BIN
Breda-Tour/Assets/UitklapIcon2.png


+ 5 - 3
Breda-Tour/Breda-Tour.csproj

@@ -97,6 +97,7 @@
     <Content Include="Assets\Flag_Icon.png" />
     <Content Include="Assets\Map_Icon.png" />
     <Content Include="Assets\UitklapIcon1.png" />
+    <Content Include="Assets\UitklapIcon2.png" />
     <Content Include="Storage\Images\1.jpg" />
     <Content Include="Storage\Images\10.jpg" />
     <Content Include="Storage\Images\11.jpg" />
@@ -159,6 +160,7 @@
       <DependentUpon>WpDetailPage.xaml</DependentUpon>
     </Compile>
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="RouteSelectScreen\BoolToString.cs" />
     <Compile Include="RouteSelectScreen\Converter.cs" />
     <Compile Include="RouteSelectScreen\RouteExample.xaml.cs">
       <DependentUpon>RouteExample.xaml</DependentUpon>
@@ -213,9 +215,9 @@
       <SubType>Designer</SubType>
     </Page>
     <Page Include="RouteSelectScreen\RouteExample.xaml">
- 		<Generator>MSBuild:Compile</Generator>
-     	<SubType>Designer</SubType>
-     </Page>    
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
     <Page Include="MapScreen\ImageViewPage.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>

+ 32 - 0
Breda-Tour/RouteSelectScreen/BoolToString.cs

@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Windows.UI.Xaml.Data;
+
+namespace Breda_Tour.RouteSelectScreen
+{
+    class BoolToString : IValueConverter
+    {
+        private object GetString(object value)
+        {
+            if (!(value is bool))
+                return "ms-appx:///Assets/UitklapIcon1.png";
+            bool objValue = (bool)value;
+            if (objValue)
+            {
+                return "ms-appx:///Assets/UitklapIcon2.png";
+            }
+            return "ms-appx:///Assets/UitklapIcon1.png";
+        }
+        public object Convert(object value, Type targetType, object parameter, string language)
+        {
+            return GetString(value);
+        }
+        public object ConvertBack(object value, Type targetType, object parameter, string language)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 3 - 1
Breda-Tour/RouteSelectScreen/RouteSelectPage.xaml

@@ -22,6 +22,7 @@
         <RelativePanel Grid.Row="2" Margin="0,5">
             <RelativePanel.Resources>
                 <con:Converter x:Key="BoolToVis"/>
+                <con:BoolToString x:Key="BoolToString"/>
             </RelativePanel.Resources>
             <ListView x:Name="Routes" ItemsSource="{x:Bind AllRoutes.Routes}" IsItemClickEnabled="True" ItemClick="Routes_ItemClick">
                 <ListView.ItemTemplate>
@@ -30,7 +31,8 @@
                             <StackPanel Orientation="Horizontal" Width="340">
                                 <Image Source="ms-appx:///Assets/Map_Icon.png" Width="35" Height="35"/>
                                 <TextBlock Text="{Binding Title}" FontSize="24" Margin="15,0,0,0"/>
-                                <ToggleButton x:Name="toggleButton" IsChecked="False"  Margin="35,0,0,0">
+                                <ToggleButton x:Name="toggleButton" Background="Transparent" IsChecked="False" Width="40" Height="40" Margin="35,0,0,0">
+                                    <Image Source="{Binding Path=IsChecked, ElementName=toggleButton,Converter={StaticResource BoolToString}}" Height="29" Margin="-10,0,-9,-1"/>
                                 </ToggleButton>
                             </StackPanel>
                             <StackPanel Orientation="Horizontal" Width="340" Visibility="{Binding Path=IsChecked, ElementName=toggleButton,Converter={StaticResource BoolToVis}}">