New to Telerik UI for WPF? Download free 30-day trial

Design-Time Error is Displayed when Setting the GuidItem Property in XAML

Environment

Product Version 2024.3.806
Product RadNotifyIcon for WPF

Description

Setting the GuidItem property of the RadNotifyIcon control displays a design-time error.

Solution

The design-time error can come from setting a value to the GuidItem property, which is not of the type of Guid.

To prevent the error from being raised, you can define the value as a resource and use a converter to convert it to a new Guid instance.

The following example showcases this approach:

Defining the Guid value as a resource

<Grid> 
    <Grid.Resources> 
        <local:StringToGuidConverter x:Key="StringToGuidConverter"/> 
        <sys:String x:Key="MyGuidString">6e39f786-db66-42ad-987a-628e1bcb3376</sys:String> 
    </Grid.Resources> 
    <telerik:RadNotifyIcon GuidItem="{Binding Source={StaticResource MyGuidString}, Converter={StaticResource StringToGuidConverter}}"/> 
</Grid> 

Implementing the converter

public class StringToGuidConverter : IValueConverter 
{ 
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 
    { 
        return Guid.Parse(value.ToString()); 
    } 
 
    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 
    { 
        throw new NotImplementedException(); 
    } 
} 
In this article