Pinning rad pane resets databound comboboxes

2 posts, 0 answers
  1. Andrew
    Andrew avatar
    37 posts
    Member since:
    Dec 2012

    Posted 02 Apr 2013 Link to this post

    I have a number of databound comboboxes in a rad pane that load fine.

    I have an issue that when I try and pin the pane all the comboboxes reset and I get

    System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='comboItems'

    a number of times.

    Where combo items is defined as

    <DataTemplate x:Key="DrillComboTemplate" >
                        <ComboBox SelectedValue="{Binding Value}" Width="{Binding Width}" HorizontalContentAlignment="{Binding Alignment}" ItemsSource="{DynamicResource comboItems}" />
                    </DataTemplate>

    Thanks

    Andy
  2. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 05 Apr 2013 Link to this post

    Hello,

    When a Pane is pinned/unpinned its content is moved to a popup and the DataContext is reset which is causing the selection of the ComboBoxes to be lost.

    All you need to do to solve this issue is to set the DataContext of the Pane. The next code snippet shows the described approach:
    <Window.Resources>
        <local:ViewModel x:Key="ViewModel"/>
    </Window.Resources>
         
    <Grid DataContext="{StaticResource ViewModel}" x:Name="LayoutGrid">
        <telerik:RadDocking>
            <telerik:RadSplitContainer>
                <telerik:RadPaneGroup>
                    <telerik:RadPane Header="Pane 1" DataContext="{Binding ElementName=LayoutGrid, Path=DataContext}">
                        <StackPanel>
                            <ComboBox ItemsSource="{Binding Items}"
                                        DisplayMemberPath="Name"
                                        SelectedIndex="0"/>
                        </StackPanel>
                    </telerik:RadPane>
                </telerik:RadPaneGroup>
            </telerik:RadSplitContainer>
        </telerik:RadDocking>
    </Grid>

    Hope this is helpful.

    Regards,
    Vladi
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top