I am making a WPF application with a sidebar for navigating through different pages which are loaded onto a frame. As any other sidebar, the clicked sidebar radiobutton is highlighted when clicked.
Now, the problem I am facing is that the pages I need to navigate to are rather heavy, with about 20+ checkboxes, 20+ textboxes, 20+ labels, and some more controls. So on the click of the radiobutton on the sidebar, there is a considerable delay till the page being navigated and thus the radiobutton being highlighted. I managed to show a loading window everytime the frame is navigating, however I can't think of a way to remove the delay between the radiobutton being clicked and being highlighted.
This question would've been helpful to me however there is a difference. I am using the style to highlight the radiobutton right away using a trigger. The style of my radiobutton is as below:
<Style x:Key="MenuRadioButtonStyle" TargetType="{x:Type RadioButton}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{DynamicResource PrimaryGrayColor}"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="FontWeight" Value="Normal"/>
<Setter Property="FontSize" Value="15"/>
<Setter Property="Height" Value="40"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<Border x:Name="menuButton" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="45"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<!-- Selected -->
<Border x:Name="btnSelected" Grid.ColumnSpan="2" CornerRadius="4" Width="210" HorizontalAlignment="Right"/>
<!-- Indicator -->
<Rectangle x:Name="Indicator" HorizontalAlignment="Left" Width="4" Height="40" VerticalAlignment="Center" RadiusX="2" RadiusY="2"/>
<!-- Icon -->
<Path x:Name="Icon" Data="{Binding Tag, RelativeSource={RelativeSource AncestorType={x:Type RadioButton}}}" Height="24" Width="24" Stretch="None" Fill="{DynamicResource PrimaryGrayColor}" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0 0 5 0"/>
<!-- Text -->
<TextBlock x:Name="txtName" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="12 0 0 0"
Grid.Column="1" Text="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}"
FontWeight="{TemplateBinding FontWeight}"
FontSize="{TemplateBinding FontSize}"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="txtName" Property="Foreground" Value="{DynamicResource PrimaryBlueColor}"/>
<Setter TargetName="Icon" Property="Fill" Value="{DynamicResource PrimaryBlueColor}"/>
<!-- Optional
<Setter TargetName="Indicator" Property="Fill" Value="red"/>
<Setter TargetName="Indicator" Property="Height" Value="20"/>-->
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="Icon" Property="Fill" Value="{DynamicResource PrimaryBlueColor}"/>
<Setter TargetName="Indicator" Property="Fill" Value="{DynamicResource PrimaryBlueColor}"/>
<Setter TargetName="Indicator" Property="Height" Value="20"/>
<Setter TargetName="btnSelected" Property="Background" Value="{DynamicResource SecundaryGrayColor}"/>
<Setter TargetName="txtName" Property="Foreground" Value="{DynamicResource PrimaryBlueColor}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Thanks in advance.