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

How to acces element in TitleTemplate of RadPane (second try)

3 Answers 106 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Stefan Babinec
Top achievements
Rank 1
Stefan Babinec asked on 14 Apr 2010, 11:40 AM

Hello.

I've created simple style for my RadPane.
I'm setting there also DataTemplate of TitleTemplate.
I've got problem to acces programatically the element in this DataTemplate from the class on which this style is applied.
For example I'd like to acces somehow the "PART_ParentControls" element in the following simple style.

Can you please, help ?

I would really appreciate that.

Thanks a lot.

Stefan.

<Style x:Key="TelerikRadPaneStyle" TargetType="{x:Type telDockingControls:RadPane}">  
        <Setter Property="CanUserPin" Value="False" /> 
        <Setter Property="CanFloat" Value="True" /> 
        <Setter Property="CanUserClose" Value="False" /> 
        <Setter Property="ContextMenuTemplate">  
            <Setter.Value> 
                <DataTemplate> 
                    <telNavigationControls:RadContextMenu Visibility="Collapsed" /> 
                </DataTemplate> 
            </Setter.Value> 
        </Setter> 
        <Setter Property="TitleTemplate">  
            <Setter.Value> 
                <DataTemplate > 
                    <Grid > 
                        <Grid.ColumnDefinitions> 
                            <ColumnDefinition Width="*" /> 
                        </Grid.ColumnDefinitions> 
 
                        <Grid Grid.Column="0" x:Name="PART_ParentControls" /> 
 
                    </Grid> 
              </DataTemplate> 
         </Setter.Value> 
    </Setter> 
</Style> 

3 Answers, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 15 Apr 2010, 02:43 PM
Hello Stefan,

There is no way to find an element from DataTemplate, because of the nature of the DataTemplate - it represents a factory for visual elements and there could be many instances of the visual tree of the DataTemplate. What you could do is to search the visual tree with the VisualTreeHelper static class and to try to find you element, but this is considered as bad practice. What I would suggest you is to change the way you want to achive you goal and to consider a different approach - for example using data binding.

Kind regards,
Miroslav Nedyalkov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Marco
Top achievements
Rank 1
answered on 22 Jul 2010, 11:03 AM
I have a similar problem and I'd like to use Binding to solve it but I cannot let it work.
This is my DataTemplate:

 

 

<DataTemplate x:Key="TitleTemplate">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="50" />
                <ColumnDefinition Width="50" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
  
            <ContentPresenter Content="{Binding}" 
                              Name="titleTemplate"
                              Margin="0,0,0,0"
                            />
            <StackPanel Orientation="Horizontal" Grid.Column="1">
                <telerik:RadButton Name="btnMinimize" 
                                   Grid.Column="1"
                                       Content="_"
                                       Command="local:AdvancedDockingWindow.MinimizeCommand"
                                       Visibility="{Binding IsFloating,  RelativeSource={RelativeSource Mode=FindAncestor}, Converter={StaticResource BooleanToVisibilityConverter}}"
                                       >
                </telerik:RadButton>
                <telerik:RadButton Name="btnMaximize"
                                    Grid.Column="2"
                                       Content="-"
                                       Command="local:AdvancedDockingWindow.MaximizeCommand"
                                       Visibility="{Binding IsFloating,  RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}"
                                       >
                </telerik:RadButton>
            </StackPanel>
        </Grid>
    </DataTemplate>

What I'd like to do is to add 2 buttons in the floating window and make them visible only when the pane has IsFloating property set to true.At the moment the 2 buttons are correctly shown in the header but I'm not able to hide them because the binding is not working. I also tried with the

 

FindAncestor

 

 

instead of Mode=TemplatedParent but still nothing. Any Idea how should I set the binding on the buttons to solve this problem?

Thank you in advance,

Marco 

 

 

 

0
George
Telerik team
answered on 27 Jul 2010, 03:26 PM
Hello Marco,

Thank you for contacting us.

Attached you can find a sample that illustrates how to bind visibility of the radbuttons in TitleTemplate. I hope this will suit your needs.

Please do not hesitate to contact us if you require any further information.

Greetings,
George
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Docking
Asked by
Stefan Babinec
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Marco
Top achievements
Rank 1
George
Telerik team
Share this question
or