I have two buttons that work perfectly. I control the visibility: 1. One Button disappears and is replaced by the other Button. 2. The image is an arrow that points left or right. 2. The Color border changes as it should.
This works, but it feels kludgy. I believe this should be done with a ToggleButton, but I can't get a ToggleButton to work correctly.
Working Buttons:
<Button Name="ActiveJobGridButtonRight" Grid.Row="1" Grid.Column="2"
Command="{Binding JobGridListViewVisibility}"
Style="{DynamicResource GraphicIconStyle}" IsEnabled="True"
Visibility="{Binding JobViewGridVisible, Converter={StaticResource ReverseBooleanToVisibilityConverter}, UpdateSourceTrigger=PropertyChanged}"
ToolTip="Expand Jobs List">
<Image Source="/Graphics/arrow_right24.png" Width="24" Height="24" Margin="0"></Image>
</Button>
<Button Name="ActiveJobGridButtonLeft" Grid.Row="1" Grid.Column="2"
Command="{Binding JobGridListViewVisibility}"
Style="{DynamicResource GraphicIconStyle}" IsEnabled="True"
Visibility="{Binding JobViewGridVisible, Converter={StaticResource booleanToVisibility}, UpdateSourceTrigger=PropertyChanged}"
ToolTip="Collapse Jobs List">
<Border BorderBrush="{Binding Path=JobViewGridVisible, Converter={StaticResource SecurityAccessBrushColorConverter}}"
BorderThickness="2" CornerRadius="4">
<Image Source="/Graphics/arrow_left24.png" Width="24" Height="24" Margin="0"></Image>
</Border>
</Button>
My ToggleButton Attempt:
<ToggleButton x:Name="EmployeeListViewExpansionToggleButton" Grid.Row="1" Grid.Column="2" Width="28" Height="28"
Background="Transparent" BorderThickness="0">
<Border BorderBrush="{Binding ElementName=EmployeeListViewExpansionToggleButton, Path=IsChecked, Converter={StaticResource SecurityAccessBrushColorConverter}}"
BorderThickness="2" CornerRadius="4" Background="Transparent">
<Image Source="/Graphics/arrow_right24.png" Width="24" Height="24" Margin="0" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<ScaleTransform ScaleX="{Binding ElementName=EmployeeListViewExpansionToggleButton, Path=IsChecked, Converter={StaticResource BooleanToRotationConverter}}"/>
</Image.RenderTransform>
</Image>
</Border>
</ToggleButton>
Converter:
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var b = (bool)value;
if (b)
{
return -1;
}
else
{
return 1;
}
}
