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
close icon

TreeViewAdv programmatically

Hi,

I have a some group data: Group1, Group2, ..., GroupN.
Each of the groups have input and outputs parameters, 

Image attached.

I'm trying to build a tree programmatically:


foreach (var plugin_ in Plugins)
{
var modelName = new TreeViewItemAdv
{
Header = plugin_.Key,
CollapsedImageSource = new BitmapImage(new Uri(@"Images/folder20.png", UriKind.Absolute)),
ExpandedImageSource = new BitmapImage(new Uri(@"Images/expanderFolder20.png", UriKind.Absolute)),
AllowDrop = false,
IsExpanded = true,
IsEditable = false
};
Item1.Items.Add(modelName);
var inputValues = new TreeViewItemAdv()
{
Header = "InputParameters",
        CollapsedImageSource = new BitmapImage(new Uri(@"Images/folder20.png", UriKind.Absolute)),
ExpandedImageSource = new BitmapImage(new Uri(@"Images/expanderFolder20.png", UriKind.Absolute)),
Uid = "InputGroup",
AllowDrop = false,
IsExpanded = true,
IsEditable = false
};
modelName.Items.Add(inputValues);
foreach (var value in plugin_.Value.InputParameters)
{
var val = new TreeViewItemAdv()
{
Header = value.Description + " (" + value.Name + ")",
Name = value.Name,
LeftImageSource = new BitmapImage(new Uri(@"Images/Line_Chart.png", UriKind.Absolute)),
IsEditable = false,
AllowDrop = false,
Uid = "Curve",
IsExpanded = true
};
var bnd = new Binding("ImgConvert")
{
Source = ApplicationContext.Current.DataManager.Parameters,
Converter = new CurveDefinedToImageConverter(),
                        Path = new PropertyPath("IsDefined"),
                        Mode = BindingMode.OneWay,
                        ConverterParameter = "Curve"
};
        val.SetBinding(TreeViewItemAdv.RightImageSourceProperty, bnd);
}
}


public class CurveDefinedToImageConverter : IValueConverter
    {
        public object Convert(object value, Type targetType,
                              object parameter, CultureInfo culture)
        {
            var loaded = (bool)value;
            return new BitmapImage(new Uri(String.Format("/MLGeomechanics2;component/Images/{0}",
                  loaded ? "accept_button.png" : "error.png"), UriKind.RelativeOrAbsolute));
        }

        public object ConvertBack(object value, Type targetType,
                                  object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

XAML:

 <syncfusion:TreeViewAdv x:Name="tree"  FontSize="12" FontWeight="Normal" syncfusion:SkinStorage.VisualStyle="Metro">
<syncfusion:TreeViewItemAdv x:Name="Item1" Header="Программные кривые" CollapsedImageSource="Images/folder20.png" ExpandedImageSource="Images/expanderFolder20.png" IsExpanded="True" IsEditable="False"  AllowDrop="False"/>
</syncfusion:TreeViewAdv>

But when the parameter in code "IsDefined" changes, RightImage does not change in GUI.

Thanks.


Attachment: 1_32dc27d8.rar

1 Reply

VR Venkateshwaran Ramdoss Syncfusion Team April 17, 2017 12:59 PM UTC

Hi Lurii, 
 
Thank you for contacting Syncfusion Support. 
 
We have checked the reported issue with the given code example. We suspect that the reported issue may occur due to the BindingMode as OneWay in the converters used in your sample. Could you please check the below code example and reset the converter Binding Mode as TwoWay?   
 
 
var bnd = new Binding("ImgConvert") 
        { 
            Source = ApplicationContext.Current.DataManager.Parameters, 
            Converter = new CurveDefinedToImageConverter(), 
            Path = new PropertyPath("IsDefined"), 
            Mode = BindingMode.TwoWay, 
            ConverterParameter = "Curve" 
        }; 
 
 
Since we could not replicate same sample as like your based on the provided details, Could you please check with the above solution and let us know if it is helpful. Otherwise please share us more details about your query like providing issue replicable sample and replication steps which is helpful us to provide prompt solution at earliest. 
 
 
Regards, 
Venkateshwaran V.R. 
 
 


Loader.
Live Chat Icon For mobile
Up arrow icon