This is a migrated thread and some comments may be shown as answers.

How to disable radtreeview validation

1 Answer 127 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
cman
Top achievements
Rank 1
cman asked on 22 Jan 2013, 04:48 PM
I am binding my radtreeview to a collectionviewsource that is grouped on the employee's last name initial (A, B, C, etc.).  I also bind the selecteditem to a property on my viewmodel which is of type Employee.  The problem is that when I select the parent node (A, B, C, etc.) it fails validation and gives me a red border.  I want to override that and disable it.

Private _selectedItem As Library.EmployeeInfo
Public Property SelectedItem As Library.EmployeeInfo
    Get
        Return _selectedItem
    End Get
    Set(ByVal value As Library.EmployeeInfo)
        If IsBusy Then Return
        _selectedItem = value
        NotifyOfPropertyChange(Function() SelectedItem)
        Events.Publish(New SelectionChangedEvent(Of EmployeeListViewModel, Library.EmployeeInfo) With {.Source = Me, .Obj = Me.SelectedItem})
    End Set
End Property


    <Grid.Resources>
        <bengenconv:SingleCharacterConverter x:Key="SingleCharacterConverter" />
        <CollectionViewSource x:Key="Emps"
                              Source="{Binding Model}">
            <CollectionViewSource.SortDescriptions>
                <componentModel:SortDescription PropertyName="Lastname" />
                <componentModel:SortDescription PropertyName="Firstname" />
                <componentModel:SortDescription PropertyName="EmployeeIdNumber" />
            </CollectionViewSource.SortDescriptions>
            <CollectionViewSource.GroupDescriptions>
                <PropertyGroupDescription PropertyName="Lastname"
                                          Converter="{StaticResource SingleCharacterConverter}" />
            </CollectionViewSource.GroupDescriptions>
        </CollectionViewSource>
        <DataTemplate x:Key="EmployeeTemplate">
            <TextBlock>
                <TextBlock.Text>
                    <MultiBinding StringFormat="{}{0}, {1}">
                        <Binding Path="Lastname" />
                        <Binding Path="Firstname" />
                    </MultiBinding>
                </TextBlock.Text></TextBlock>
        </DataTemplate>
        <HierarchicalDataTemplate x:Key="GroupsTemplate"
                                  ItemsSource="{Binding Items}"
                                  ItemTemplate="{StaticResource EmployeeTemplate}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Name}"/>
                <TextBlock Text="{Binding ItemCount, StringFormat='  ({0})'}"
                           FontSize="11"
                           FontStyle="Italic"
                           Foreground="DimGray"
                           VerticalAlignment="Center"/>
            </StackPanel>
        </HierarchicalDataTemplate>
    </Grid.Resources>
    <telerik:RadTreeView x:Name="xTreeView"
                         ItemsSource="{Binding Source={StaticResource Emps}, Path=Groups}"
                         Grid.Row="1"
                         Padding="5"
                         BorderThickness="0"
                         IsEditable="False"
                         SelectionMode="Single"
                         SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                         ItemTemplate="{StaticResource GroupsTemplate}"
                         IsSingleExpandPath="True"
                         IsExpandOnSingleClickEnabled="True">
    </telerik:RadTreeView>
</Grid>

1 Answer, 1 is accepted

Sort by
0
cman
Top achievements
Rank 1
answered on 22 Jan 2013, 04:55 PM
As seems typical after posting, I found an answer that disables the validation on that control.  I still wonder if there's a better way to accomplish the same thing without disabling validation.  But here's what I found in case someone else needs it.
<telerik:RadTreeView x:Name="xTreeView" ... >
    <Validation.ErrorTemplate>
        <ControlTemplate />
    </Validation.ErrorTemplate>
</telerik:RadTreeView>
Tags
TreeView
Asked by
cman
Top achievements
Rank 1
Answers by
cman
Top achievements
Rank 1
Share this question
or