I've been trying to implement just the Identify functionality of the sample code into my application. I'm having difficulty adding the ToVisibilityConverter function which is the key to toggling the Identify action.In MainPage.xaml, I have:
<UserControl.Resources>
<DropShadowEffect x:Name="dropShadow" BlurRadius="10" ShadowDepth="10" Direction="-45" Color="Black" Opacity="0.5" />
<local:ToVisibilityConverter x:Key="ToVisibility" />
</UserControl.Resources>
<!-- Identify Window -->
<local:WindowPanel x:Name="IdentifyPanel" Width="260" Height="364" Effect="{StaticResource dropShadow}"
Background="{StaticResource CommonBackgroundBrush}"
Visibility="{Binding ElementName=Identify, Path=IsActive, Mode=TwoWay, Converter={StaticResource ToVisibility}}"
VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" HorizontalAlignment="Left" VerticalAlignment="Top"
Margin="30,200,0,0"
BorderBrush="{StaticResource CommonBorderBrush}" >
<local:Identify x:Name="Identify" Map="{Binding ElementName=Map}" IsActive="False"/>
<local:WindowPanel.ContentTitle>
<StackPanel Orientation="Horizontal">
<Image Source="Images/IdentifyTool.png"
HorizontalAlignment="Left" VerticalAlignment="Top" Stretch="Fill"
Width="20" Height="20" Margin="5,2,0,0" />
<TextBlock Foreground="White" FontSize="12"
Text="Identify" TextWrapping="NoWrap" Height="Auto"
HorizontalAlignment="Left" Margin="5,3,0,0" />
</StackPanel>
</local:WindowPanel.ContentTitle>
</local:WindowPanel>In MainPage.xaml.cs, I've added the following: #region ToVisibilityConverter
public sealed class ToVisibilityConverter : IValueConverter
{
// Methods
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool flag = false;
if (value is bool)
{
flag = (bool)value;
}
else if (value is bool?)
{
bool? nullable = (bool?)value;
flag = nullable.HasValue ? nullable.Value : false;
}
else if (value is int)
{
flag = ((int)value != 0);
}
else if (value is double)
{
flag = ((double)value != 0);
}
return (flag ? Visibility.Visible : Visibility.Collapsed);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return ((value is Visibility) && (((Visibility)value) == Visibility.Visible));
}
}
#endregionHowever, when I build the solution, it says that I don't have the ToVisibilityConverter defined. VS IDE Intellisense doesn't show that method for my application namespace. What am I missing?