We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

I get bind error when SymbolsDisplayMode="NamesUnderIcons" in Stencil.

As I mentioned in the title, when I set SymbolsDisplayMode="NamesUnderIcons" in Stencil, I get the following error.


Error : 

Cannot convert '<null>' from type '<null>' to type 'System.Windows.Media.ImageSource' for 'en-US' culture with default conversions; consider using Converter property of Binding. NotSupportedException:'System.NotSupportedException: ImageSourceConverter cannot convert from (empty).


        <Syncfusion:Stencil Grid.Column="0"

                            ExpandMode="All"

                            ShowDisplayModeToggleButton="False"

                            SymbolsDisplayMode="NamesUnderIcons"

                            ShowSearchTextBox="False">

            <Syncfusion:Stencil.SymbolSource>

                <Syncfusion:SymbolCollection>

                    <viewModels:StencilSymbolViewModel Symbol="/Images/Gray30x40.png"

                                                       Name="30x40"

                                                       Type="Seat"

                                                       Width="30"

                                                       Height="40"

                                                       SymbolTemplateKey="SymbolTemplate"

                                                       Key="Small Size" />

                    <viewModels:StencilSymbolViewModel Symbol="/Images/Gray48x64.png"

                                                       Name="48x64"

                                                       Type="Seat"

                                                       Width="48"

                                                       Height="64"

                                                       SymbolTemplateKey="SymbolTemplate"

                                                       Key="Medium Size" />


                    <viewModels:StencilSymbolViewModel Symbol="/Images/Wc64x64.png"

                                                       Name="64x64"

                                                       Type="Picture"

                                                       Width="64"

                                                       Height="64"

                                                       SymbolTemplateKey="PictureTemplate"

                                                       Key="Pictures" />


                </Syncfusion:SymbolCollection>

            </Syncfusion:Stencil.SymbolSource>

            <Syncfusion:Stencil.SymbolGroups>

                <Syncfusion:SymbolGroups>

                    <Syncfusion:SymbolGroupProvider MappingName="Key">

                    </Syncfusion:SymbolGroupProvider>

                </Syncfusion:SymbolGroups>

            </Syncfusion:Stencil.SymbolGroups>

        </Syncfusion:Stencil>



2 Replies 1 reply marked as answer

PP Prakash Perumal Syncfusion Team March 29, 2023 05:24 AM UTC

Hi Özgür,


We can be able to reproduce the reported binding error when setting SymbolsDisplayMode property as NamesUnderIcons. We are investigating the issue and will provide you with more information by March 30, 2023.


Regards,

Prakash



KR Karkuvel Rajan Shanmugavel Syncfusion Team March 30, 2023 01:33 PM UTC

Hi Özgür,


We suggest adding a converter for the Binding Expression used to set the source for the Image in the Symbol Template to resolve the Binding Error that arises when setting the SymbolsDisplayMode as NamesUnderIcons. Please refer to the provided converter codes and template codes.


 

    public class ImageStreamConverter : IValueConverter

    {

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)

        {

            return value;

        }

 

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

        {

            throw new InvalidOperationException("type");

        }

    }

 

 

            <local:ImageStreamConverter x:Key="imageStreamConverter"/>

 

            <DataTemplate x:Key="SymbolTemplate">

                <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">

                    <Image Source="{Binding Converter={StaticResource imageStreamConverter}}"/>

                </Grid>

            </DataTemplate>

 



Regards,

Karkuvel Rajan S


Marked as answer
Loader.
Up arrow icon