Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How do I convert a combobox text to Visibility of another element?

$
0
0

I currently have on the target element a 

 Visibility="{Binding ElementName=SourceElement, Path=SelectedItem, Converter={StaticResource TextToVisibility}}"

The coverter includes

    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            switch (value.ToString())
            {
                case "Yes":
                    return Visibility.Visible;
                case "No":
                    return Visibility.Collapsed;
            }
            return Visibility.Collapsed;
        } 

However, it gives an exception on launch about "Object reference not set to an instance of an object." right on the "switch (value.ToString())" line

The SourceElement (a Combobox) is also bound; to a DataGrid cell (on a selected line) and it has a converter there. I wonder if that's related. That converter there basically turns true or false from the datagrid to yes or no.





Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>