This question is locked. New answers and comments are not allowed.
How to change Expander button at runtime?
I have this buttons:http://demos.telerik.com/silverlight/#TreeView/FirstLook
But i want somethin like this: http://demos.telerik.com/silverlight/#TreeView/LoadOnDemand
The control template in this page: http://www.telerik.com/help/silverlight/radtreeview-expander-style.html doesnt work for me,
there is another way?
I have this buttons:http://demos.telerik.com/silverlight/#TreeView/FirstLook
But i want somethin like this: http://demos.telerik.com/silverlight/#TreeView/LoadOnDemand
The control template in this page: http://www.telerik.com/help/silverlight/radtreeview-expander-style.html doesnt work for me,
there is another way?
3 Answers, 1 is accepted
0
Hi Joe,
What is the problem with the code from the help article?
You can copy the style of the expander button from the examples and to have the same effect.
I'm pasting the code here for your convenience:
| <UserControl.Resources> |
| <Style x:Key="ExpanderStyle1" TargetType="ToggleButton"> |
| <Setter Property="IsEnabled" Value="True" /> |
| <Setter Property="IsTabStop" Value="False" /> |
| <Setter Property="Cursor" Value="Hand" /> |
| <Setter Property="Template"> |
| <Setter.Value> |
| <ControlTemplate TargetType="ToggleButton"> |
| <Grid> |
| <VisualStateManager.VisualStateGroups> |
| <VisualStateGroup x:Name="CommonStates"> |
| <VisualState x:Name="Normal"> |
| </VisualState> |
| <VisualState x:Name="MouseOver"> |
| <Storyboard> |
| <DoubleAnimation Duration="0:0:0.05" |
| Storyboard.TargetName="Button" |
| Storyboard.TargetProperty="Opacity" To="0" /> |
| <DoubleAnimation Duration="0:0:0.05" |
| Storyboard.TargetName="ButtonOver" |
| Storyboard.TargetProperty="Opacity" To="1" /> |
| </Storyboard> |
| </VisualState> |
| </VisualStateGroup> |
| <VisualStateGroup x:Name="CheckStates"> |
| <VisualState x:Name="Checked"> |
| <Storyboard> |
| <DoubleAnimation Duration="0:0:0.05" |
| Storyboard.TargetName="CollapsedVisual" |
| Storyboard.TargetProperty="Opacity" To="0" /> |
| <DoubleAnimation Duration="0:0:0.05" |
| Storyboard.TargetName="CollapsedVisualOver" |
| Storyboard.TargetProperty="Opacity" To="0" /> |
| </Storyboard> |
| </VisualState> |
| <VisualState x:Name="Unchecked"> |
| <Storyboard> |
| <DoubleAnimation Duration="0:0:0.05" |
| Storyboard.TargetName="CollapsedVisual" |
| Storyboard.TargetProperty="Opacity" To="1" /> |
| <DoubleAnimation Duration="0:0:0.05" |
| Storyboard.TargetName="CollapsedVisualOver" |
| Storyboard.TargetProperty="Opacity" To="1" /> |
| </Storyboard> |
| </VisualState> |
| </VisualStateGroup> |
| </VisualStateManager.VisualStateGroups> |
| <Grid x:Name="Button" Margin="0,7,4,0" HorizontalAlignment="Right" |
| VerticalAlignment="Top" Width="11" Height="11"> |
| <Grid.Background> |
| <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> |
| <GradientStop Color="#3F047BA5" Offset="0.996" /> |
| <GradientStop Color="#00000000" Offset="0" /> |
| </LinearGradientBrush> |
| </Grid.Background> |
| <Rectangle Stroke="#FF000000" HorizontalAlignment="Left" |
| VerticalAlignment="Top" Width="11" Height="11" /> |
| <Rectangle x:Name="CollapsedVisual" Fill="#FF000000" |
| HorizontalAlignment="Left" VerticalAlignment="Top" Width="1" |
| Height="5" Margin="5,3,0,0" /> |
| <Rectangle Fill="#FF000000" VerticalAlignment="Top" |
| HorizontalAlignment="Left" Height="1" Width="5" |
| Margin="3,5,0,0" /> |
| </Grid> |
| <Grid x:Name="ButtonOver" Margin="0,7,4,0" HorizontalAlignment="Right" |
| VerticalAlignment="Top" Width="11" Height="11"> |
| <Rectangle Stroke="#FF167497" HorizontalAlignment="Left" |
| VerticalAlignment="Top" Width="11" Height="11"> |
| <Rectangle.Fill> |
| <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> |
| <GradientStop Color="#26167497" Offset="1" /> |
| <GradientStop Color="#00167497" Offset="0" /> |
| </LinearGradientBrush> |
| </Rectangle.Fill> |
| </Rectangle> |
| <Rectangle x:Name="CollapsedVisualOver" Fill="#FF167497" |
| HorizontalAlignment="Left" VerticalAlignment="Top" Width="1" |
| Height="5" Margin="5,3,0,0" /> |
| <Rectangle Fill="#FF167497" VerticalAlignment="Top" |
| HorizontalAlignment="Left" Height="1" Width="5" |
| Margin="3,5,0,0" /> |
| </Grid> |
| </Grid> |
| </ControlTemplate> |
| </Setter.Value> |
| </Setter> |
| </Style> |
| <DataTemplate x:Key="OrdersTemplate"> |
| <StackPanel Orientation="Horizontal"> |
| <TextBlock Text="OrderID : " /> |
| <TextBlock Text="{Binding OrderID}" /> |
| </StackPanel> |
| </DataTemplate> |
| <core:HierarchicalDataTemplate x:Key="ProductTemplate" ItemsSource="{Binding OrderDetails}" |
| ItemTemplate="{StaticResource OrdersTemplate}"> |
| <TextBlock Text="{Binding ProductName}" /> |
| </core:HierarchicalDataTemplate> |
| <core:HierarchicalDataTemplate x:Key="CategoryTemplate" ItemsSource="{Binding Products}" |
| ItemTemplate="{StaticResource ProductTemplate}"> |
| <TextBlock Text="{Binding Name}" /> |
| </core:HierarchicalDataTemplate> |
| </UserControl.Resources> |
| <Grid Width="300" Height="320" HorizontalAlignment="Center" VerticalAlignment="Center"> |
| <Border BorderBrush="#FF000000" CornerRadius="5" BorderThickness="5" Background="#FFFFFFFF"> |
| <telerik:RadTreeView Name="treeView" ItemTemplate="{StaticResource CategoryTemplate}" ExpanderStyle="{StaticResource ExpanderStyle1}" |
| IsLoadOnDemandEnabled="True" /> |
| </Border> |
| </Grid> |
Best wishes,
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Joe
Top achievements
Rank 1
answered on 14 May 2009, 09:03 AM
Thank u for the reply, but the code doesnt work, because the Treeview is within a StackPanel and PanelBar.
0
Hello Joe,
It doesn't matter where the treeview is declared - it should work.
Can you send me a project that I can investigate and modify.
Thanks!
All the best,
Valentin.Stoychev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
It doesn't matter where the treeview is declared - it should work.
Can you send me a project that I can investigate and modify.
Thanks!
All the best,
Valentin.Stoychev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
