-2

I am new on silverlight development. During my activity i have encountered an error which is i mentioned on the title of this post. My main purpose is popup date picker when clicking button.

 <ToggleButton  x:Name="TogglePopupButton" HorizontalAlignment="Right" Height="26" VerticalAlignment="Center" Grid.Column="1" Style="{StaticResource ToolIconToggleButtonStyle}" Width="26" 
               IsEnabled="{Binding ElementName=ToggledPopup, Path=IsOpen,Converter={StaticResource BoolToInvertedBoolConverter}}">

this is .xaml

<UserControl
<xmlns:local="clr-namespace:US.Payment.Web.Modules.PaymentMachine.Utils">
<UserControl.Resources>
    <US_Payment_Web_Converters:GroupRowHeaderVisibilityConverter x:Key="GroupRowHeaderVisibilityConverter"/>
    <viewModel:ImportUSPViewModel x:Name="ViewModel"/>
    <local:AmountValuesConverter x:Name="AmountConverter"/>
    <local:BackgroundConverter x:Key="BackgroundConverter" />
    <local:BoolToInvertedBoolConverter  x:Key="BoolToInvertedBoolConverter " />
    <Style x:Key="CalendarDayButtonStyle1" TargetType="prim:CalendarDayButton">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="prim:CalendarDayButton">
                    <Grid Background= "{Binding Converter={StaticResource BackgroundConverter}, Path=Date}">
                        <ContentControl x:Name="Content" Margin="5,1,5,1" Content="{TemplateBinding Content}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</UserControl.Resources>

This is BoolToInvertedBoolConverter.cs file

 public class BoolToInvertedBoolConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        if (value is bool)
        {
            bool boolValue = (bool)value;
            return !boolValue;
        }
        else
            return false;
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException("ConvertBack() of BoolToInvertedBoolConverter is not implemented");
    }
}
Lasal Senarath
  • 149
  • 1
  • 13

1 Answers1

3

The problem is, you accidentally put a space character at the and of the x:Key value when declaring your resource. Remove that character and it will work.

x:Key="BoolToInvertedBoolConverter "-> has space at the end but should be

x:Key="BoolToInvertedBoolConverter" -> without space.

NthDeveloper
  • 969
  • 8
  • 16