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

Setting OpenIcon & CloseIcon from Code Behind to a non image file

Hello,

I'm wondering if the CloseIcon and OpenIcon can be bound to a unicode value somehow in the code behind?

I'm converting my app to incorporate Syncfusion, and I have a page using BackdropPage, but I'd like to customize the icons without forcing a local or embedded image. I have other places in my app where I declare an image based on the glyph unicode from a font I loaded. I do that with FontImageSource within the Image.Source reference in XAML
<Image>
    <Image.Source>
         <FontImageSource/>
    </Image.Source>
</Image>

Can I manipulate these resources in SfBackdropPage in a similar way?

1 Reply

RA Rachel A Syncfusion Team August 6, 2019 10:12 AM UTC

 
 
You can place the FontImageSource in the place of Open and Close icon of the SfBackdrop page. We have achieved this requirement using the toolbar item clicked event. Please find the below code snippet and sample for your reference. 
 
[C#] 
 
public MainPage()
{
            InitializeComponent();

            ToolbarItems[0].Clicked += Handle_Clicked;
}

void Handle_Clicked(object sender, EventArgs e)
{
            FontImageSource fontImageSource = new FontImageSource();

            fontImageSource.FontFamily = Device.RuntimePlatform == Device.Android ? "UIFontIcons.ttf#UIFontIcons" : Device.RuntimePlatform == Device.iOS ? "UIFontIcons" : "Assets/UIFontIcons.ttf#UIFontIcons";
            fontImageSource.Color = Color.Red;

            if (((sender as ToolbarItem).Parent as SfBackdropPage).IsBackLayerRevealed)
            {
                fontImageSource.Glyph = "\ue72d";
            }
            else
            {
                fontImageSource.Glyph = "\ue709";
            }

            (sender as ToolbarItem).IconImageSource = fontImageSource;
}
 
 
Please follow the below procedure to add font file for each platform. 
 
 
Please let us know if you need further assistance on this. 
 
Regards, 
Rachel. 


Loader.
Live Chat Icon For mobile
Up arrow icon