How to disable radtreeview validation

2 posts, 0 answers
  1. cman
    cman avatar
    3 posts
    Member since:
    Jul 2011

    Posted 22 Jan 2013 Link to this post

    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>
  2. cman
    cman avatar
    3 posts
    Member since:
    Jul 2011

    Posted 22 Jan 2013 Link to this post

    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>
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top