Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 84751

WPF RadTreeView is generating the following warnings and I don't understand why?

$
0
0

Hi Telerik,

 

I am having the following issue: 

I have a RadTreeView with ItemTemplateSelector. The ItemTemplateSelector can assign one of the two templates for every tree node. Most of the time everything works perfectly fine but once every twenty times I load the screen with the treeview and only the root nodegets through the SelectTemplate method - the other nodes don't hit it. I decided to report this issue here as I receive the same error in the output:

 

PresentationHost.exe Information: 0 : app.Procast_SP_ADMIN_ApplySelectionGetList: <GetList><User_Idx>13</User_Idx><SalesOrg_Idx>1</SalesOrg_Idx><MenuItem_Idx>21</MenuItem_Idx><SelectedItems><Item_Idx>2</Item_Idx><Item_Idx>8</Item_Idx><Item_Idx>20051</Item_Idx><Item_Idx>20080</Item_Idx><Item_Idx>7</Item_Idx><Item_Idx>20039</Item_Idx><Item_Idx>20077</Item_Idx></SelectedItems></GetList>

System.Windows.Data Error: 23 : Cannot convert '<null>' from type '<null>' to type 'System.Windows.Media.Brush' for 'en-GB' culture with default conversions; consider using Converter property of Binding. NotSupportedException:'System.NotSupportedException: BrushConverter cannot convert from (null).
   at System.ComponentModel.TypeConverter.GetConvertFromException(Object value)
   at System.Windows.Media.BrushConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)'
System.Windows.Data Error: 23 : Cannot convert '<null>' from type '<null>' to type 'System.Windows.Media.Brush' for 'en-GB' culture with default conversions; consider using Converter property of Binding. NotSupportedException:'System.NotSupportedException: BrushConverter cannot convert from (null).
   at System.ComponentModel.TypeConverter.GetConvertFromException(Object value)
   at System.Windows.Media.BrushConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)'
System.Windows.Data Error: 25 : Both 'ItemTemplate' and 'ItemTemplateSelector' are set;  'ItemTemplateSelector' will be ignored. RadTreeViewItem:'RadTreeViewItem' (Name='')
System.Windows.Data Error: 25 : Both 'HeaderTemplate' and 'HeaderTemplateSelector' are set;  'HeaderTemplateSelector' will be ignored. RadTreeViewItem:'RadTreeViewItem' (Name='')
System.Windows.Data Error: 23 : Cannot convert '<null>' from type '<null>' to type 'System.Windows.Media.Brush' for 'en-GB' culture with default conversions; consider using Converter property of Binding. NotSupportedException:'System.NotSupportedException: BrushConverter cannot convert from (null).
   at System.ComponentModel.TypeConverter.GetConvertFromException(Object value)
   at System.Windows.Media.BrushConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)'
System.Windows.Data Error: 23 : Cannot convert '<null>' from type '<null>' to type 'System.Windows.Media.Brush' for 'en-GB' culture with default conversions; consider using Converter property of Binding. NotSupportedException:'System.NotSupportedException: BrushConverter cannot convert from (null).
   at System.ComponentModel.TypeConverter.GetConvertFromException(Object value)
   at System.Windows.Media.BrushConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)'
System.Windows.Data Error: 25 : Both 'ItemTemplate' and 'ItemTemplateSelector' are set;  'ItemTemplateSelector' will be ignored. RadTreeViewItem:'RadTreeViewItem' (Name='')
System.Windows.Data Error: 25 : Both 'HeaderTemplate' and 'HeaderTemplateSelector' are set;  'HeaderTemplateSelector' will be ignored. RadTreeViewItem:'RadTreeViewItem' (Name='')
System.Windows.Data Error: 23 : Cannot convert '<null>' from type '<null>' to type 'System.Windows.Media.Brush' for 'en-GB' culture with default conversions; consider using Converter property of Binding. NotSupportedException:'System.NotSupportedException: BrushConverter cannot convert from (null).
   at System.ComponentModel.TypeConverter.GetConvertFromException(Object value)
   at System.Windows.Media.BrushConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)'
System.Windows.Data Error: 23 : Cannot convert '<null>' from type '<null>' to type 'System.Windows.Media.Brush' for 'en-GB' culture with default conversions; consider using Converter property of Binding. NotSupportedException:'System.NotSupportedException: BrushConverter cannot convert from (null).
   at System.ComponentModel.TypeConverter.GetConvertFromException(Object value)
   at System.Windows.Media.BrushConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)'
System.Windows.Data Error: 25 : Both 'ItemTemplate' and 'ItemTemplateSelector' are set;  'ItemTemplateSelector' will be ignored. RadTreeViewItem:'RadTreeViewItem' (Name='')
System.Windows.Data Error: 25 : Both 'HeaderTemplate' and 'HeaderTemplateSelector' are set;  'HeaderTemplateSelector' will be ignored. RadTreeViewItem:'RadTreeViewItem' (Name='')
System.Windows.Data Error: 23 : Cannot convert '<null>' from type '<null>' to type 'System.Windows.Media.Brush' for 'en-GB' culture with default conversions; consider using Converter property of Binding. NotSupportedException:'System.NotSupportedException: BrushConverter cannot convert from (null).
   at System.ComponentModel.TypeConverter.GetConvertFromException(Object value)
   at System.Windows.Media.BrushConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)'


        IsOptionElementsEnabled="{Binding IsSingleSelect, Converter={StaticResource InvertedBooleanConverter}, ElementName=Tree, Mode=TwoWay}"
        telerik:AnimationManager.IsAnimationEnabled="False"
        SelectionMode="{Binding IsSingleSelect, Converter={StaticResource BoolToSelectionModeConverter}, ElementName=Tree, Mode=TwoWay}"
        IsTriStateMode="{Binding IsSingleSelect, Converter={StaticResource InvertedBooleanConverter}, ElementName=Tree, Mode=TwoWay}"
        x:Name="MainRadTreeViewNew"
        IsVirtualizing="True"
        telerik:TreeViewPanel.TreeVirtualizationMode="Hierarchical"
        Checked="TreeView_OnChecked"
        Unchecked="TreeView_OnChecked"
        PreviewSelectionChanged="SingleSelect_OnPreviewSelected"
        Selected="SingleSelect_OnSelected"
        Unselected="SingleSelect_OnUnselected"
        ItemClick="TreeView_OnItemClick"
        ItemsSource="{Binding ElementName=Tree, Path=TreeSource.ListTree, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
        Visibility="{Binding ElementName=Tree, Path=TreeSource.IsTreeLoading, Converter={StaticResource InvertedBoolToVisibilityConverter}}" 
                        ItemTemplateSelector="{StaticResource TreeNodeTemplateSelector}"
                        >

 

This is how I declare my RadTreeView:

 

                    <telerik:RadTreeView
        IsOptionElementsEnabled="{Binding IsSingleSelect, Converter={StaticResource InvertedBooleanConverter}, ElementName=Tree, Mode=TwoWay}"
        telerik:AnimationManager.IsAnimationEnabled="False"
        SelectionMode="{Binding IsSingleSelect, Converter={StaticResource BoolToSelectionModeConverter}, ElementName=Tree, Mode=TwoWay}"
        IsTriStateMode="{Binding IsSingleSelect, Converter={StaticResource InvertedBooleanConverter}, ElementName=Tree, Mode=TwoWay}"
        x:Name="MainRadTreeViewNew"
        IsVirtualizing="True"
        telerik:TreeViewPanel.TreeVirtualizationMode="Hierarchical"
        Checked="TreeView_OnChecked"
        Unchecked="TreeView_OnChecked"
        PreviewSelectionChanged="SingleSelect_OnPreviewSelected"
        Selected="SingleSelect_OnSelected"
        Unselected="SingleSelect_OnUnselected"
        ItemClick="TreeView_OnItemClick"
        ItemsSource="{Binding ElementName=Tree, Path=TreeSource.ListTree, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
        Visibility="{Binding ElementName=Tree, Path=TreeSource.IsTreeLoading, Converter={StaticResource InvertedBoolToVisibilityConverter}}" 
                        ItemTemplateSelector="{StaticResource TreeNodeTemplateSelector}"
                        >

 

Here is the template selector:

 

    public class TreeNodeTemplateSelector : DataTemplateSelector
    {
        public DataTemplate DefaultNodeTemplate { get; set; }
        public DataTemplate DateNodeTemplate { get; set; }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            TreeViewHierarchy treeViewHierarchy = item as TreeViewHierarchy;
            if (treeViewHierarchy == null) return null;

            if (treeViewHierarchy.Template.ToLower() == "date") return DateNodeTemplate;
            return DefaultNodeTemplate;
        }
    }

 

And here are the two templates:

 

        <controls:TreeNodeTemplateSelector x:Key="TreeNodeTemplateSelector">
            
            <controls:TreeNodeTemplateSelector.DefaultNodeTemplate>
                <HierarchicalDataTemplate ItemsSource="{Binding Children, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ItemContainerStyle="{StaticResource StatusItemContainerStyle}">
                    <TextBlock Text="{Binding Name}" Background="{Binding StringBackground, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}">
                        <telerik:RadContextMenu.ContextMenu>
                        <telerik:RadContextMenu x:Name="ItemContextMenu" Opened="RadContextMenu_Opened">
                        <telerik:RadMenuItem Header="Toggle - plan at this level"  />
                        </telerik:RadContextMenu>
                        </telerik:RadContextMenu.ContextMenu>
                    </TextBlock>
                </HierarchicalDataTemplate>
            </controls:TreeNodeTemplateSelector.DefaultNodeTemplate>
            
            <controls:TreeNodeTemplateSelector.DateNodeTemplate>
                <HierarchicalDataTemplate ItemsSource="{Binding Children, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ItemContainerStyle="{StaticResource StatusItemContainerStyle}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <!--Setting fixed width for all date pickers-->
                            <ColumnDefinition Width="102"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock x:Name="Name" Text="{Binding Name}" Background="{Binding StringBackground, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center">
                            <telerik:RadContextMenu.ContextMenu>
                            <telerik:RadContextMenu x:Name="ItemContextMenu" Opened="RadContextMenu_Opened">
                            <telerik:RadMenuItem Header="Toggle - plan at this level"  />
                            </telerik:RadContextMenu>
                            </telerik:RadContextMenu.ContextMenu>
                        </TextBlock>
                        <!--
                        Height is bound so the date picker is the same height as the text block (normally is a bit bigger).
                        SelectedDateChanged handles setting dates of a node's children and parent according to the current node selection made by a user.
                        Tag holds the item idx so the node can be recognised in the SelectedDateChanged event handler.
                        -->
                        <DatePicker Grid.Column="1" SelectedDate="{Binding Date}" Height="{Binding Height, ElementName=Name}" BorderThickness="0" SelectedDateChanged="DatePicker_OnSelectedDateChanged" Tag="{Binding Idx}"/>
                    </Grid>
                </HierarchicalDataTemplate>
            </controls:TreeNodeTemplateSelector.DateNodeTemplate>
            
        </controls:TreeNodeTemplateSelector>

 

 

Let me know if you need anything else (unfortunately I'm not able to provide the full example) and feel free to move this reply if you find it posted in an inappropriate place.

 

Regars,

Jakub Siuda.


Viewing all articles
Browse latest Browse all 84751

Latest Images

Trending Articles



Latest Images

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