IsChecked Property doesn't work.

3 posts, 0 answers
  1. Steffen
    Steffen avatar
    8 posts
    Member since:
    Jan 2009

    Posted 20 Jan 2009 Link to this post

    Hi,


    I'm working on a contextmenu instantiated by code and want to use the IsChecked property, but it doesn't works: The GlyphPanel remains Collapsed and the VisualState doesn't change.

    About Style: I use my own style on contextmenu... I take all the style of Telerik dlls with reflector and change only background, border brush and border thickness properties...

    It's my first application in Silverlight... I check in the VisualStateManager if control raise the visual transition (By handling the completed event of the Storyboard that must show the GlyphPanel) and it's seems that this storyboard is never executed.

    I set all the code used, so you can maybe reproduce my problem:

    This code is the code used to generate the controls:

    public static RadMenuItem BuildRadMenuItem(string header)  
            {  
                return BuildRadMenuItem(header, null);  
            }  
     
            public static RadMenuItem BuildRadMenuItem(string header, Image icon)  
            {  
                return BuildRadMenuItem(header, icon, null);  
            }  
              
            public static RadMenuItem BuildRadMenuItem(string header, Image icon, Brush foreground)  
            {  
                var menuItem = new RadMenuItem  
                {  
                    Header = header,  
                    Icon = icon,  
                    Style = App.Current.ApplicationResources.ContextMenuItemDefaultStyle  
                };  
     
                if (foreground != null)  
                    menuItem.Foreground = foreground;  
     
                return menuItem;  
            }  
     
            public static RadContextMenu BuildRadContextMenu()  
            {  
                return new RadContextMenu  
                {  
                    Style = App.Current.ApplicationResources.ContextMenuDefaultStyle  
                };  
            } 

    The code that generate my context menu:
     
            public static void FillForDataObject(this RadContextMenu contextMenu, PartySecure partySecure)  
            {  
                if (contextMenu == null)  
                    throw new NullReferenceException();  
     
                if (partySecure == null)  
                    throw new ArgumentNullException("partySecure");  
     
                List<RadMenuItem> items = new List<RadMenuItem>();  
                  
                SecureType[] values = EnumHelper.GetValues<SecureType>();  
                foreach (SecureType memberOfSecureType in values)  
                {  
                    RadMenuItem item = ControlBuilder.BuildRadMenuItem(SecureTypeConverter.ConvertToString(memberOfSecureType));  
     
                    item.Click += (sender, e) => item.IsChecked = true;  
                    items.Add(item);  
                }  
     
                contextMenu.ItemsSource = items;  
            } 

    The code used to open the contextmenu:

    protected override void OnRightClick(RightClickEventArgs rightClickEventArgs)  
            {  
                base.OnRightClick(rightClickEventArgs);  
     
                Border border = rightClickEventArgs.Source.FindParentInVisualTree<Border>();  
     
                if (border.Tag != null && border.Tag is PartySecure)  
                {  
                    if (ActionsGridRowPartySecureContextMenu == null)  
                    {  
                        ActionsGridRowPartySecureContextMenu = ControlBuilder.BuildRadContextMenu();  
                        ActionsGridRowPartySecureContextMenu.Placement = PlacementMode.Bottom;  
                    }  
     
                    ActionsGridRowPartySecureContextMenu.IsOpen = false;  
                    ActionsGridRowPartySecureContextMenu.FillForDataObject(border.Tag as PartySecure);  
                    RadContextMenu.SetContextMenu(border, ActionsGridRowPartySecureContextMenu);  
                    ActionsGridRowPartySecureContextMenu.IsOpen = true;  
                }  
            } 

    And finally the Style from App.xaml applied to all context menus:

     <!--                                        ContextMenu Style                                               --> 
                <!-- ////////////////////////////////////////////////////////////////////////////////////////////////////// --> 
                <!-- TODO: Change SelectedBrush when needed--> 
                  
                <SolidColorBrush x:Key="SelectedBrush" Color="#FF8CBDCE"></SolidColorBrush> 
                  
                <!-- RadSeparator --> 
                <Style TargetType="telerikNav:RadSeparator">  
                    <Setter Property="Template">  
                        <Setter.Value> 
                            <ControlTemplate TargetType="telerikNav:RadSeparator">  
                                <Grid Margin="0,6,0,4">  
                                    <Rectangle Height="1" Margin="30,0,1,1" 
                                               Fill="{StaticResource SeparatorLine1}" /> 
                                    <Rectangle Height="1" Margin="30,1,1,0" 
                                               Fill="{StaticResource SeparatorLine2}" /> 
                                </Grid> 
                            </ControlTemplate> 
                        </Setter.Value> 
                    </Setter> 
                </Style> 
     
                <!-- TopLevelItem --> 
                <ControlTemplate x:Key="TopLevelItemTemplate" TargetType="telerikNav:RadMenuItem">  
                    <Grid x:Name="RootElement" Background="Transparent">  
                        <VisualStateManager.VisualStateGroups> 
                            <VisualStateGroup x:Name="CommonStateGroup">  
     
                                <VisualState x:Name="Highlighted">  
                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Bg" Storyboard.TargetProperty="Fill" Duration="0">  
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SelectedBrush}" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
     
                                <VisualState x:Name="Focused">  
                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Bg" Storyboard.TargetProperty="Fill" Duration="0">  
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SelectedBrush}" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
     
                                <VisualState x:Name="Disabled">  
                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="DisabledBox" Storyboard.TargetProperty="Visibility" Duration="0">  
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Visible}" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
     
                                <VisualState x:Name="Normal" /> 
     
                            </VisualStateGroup> 
                            <VisualStateGroup x:Name="CheckStateGroup">  
     
                                <VisualState x:Name="Checked">  
                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Icon" Storyboard.TargetProperty="Visibility" Duration="0">  
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Collapsed}" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphPanel" Storyboard.TargetProperty="Visibility" Duration="0">  
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Visible}" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
     
                                <VisualState x:Name="Unchecked" /> 
     
                                <VisualState x:Name="HideIcon">  
                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Icon" Storyboard.TargetProperty="Visibility" Duration="0">  
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Collapsed}" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
     
                            </VisualStateGroup> 
                        </VisualStateManager.VisualStateGroups> 
                          
                        <Rectangle x:Name="Bg" RadiusX="12" RadiusY="12" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" /> 
                          
                        <telerik:RadDockPanel MinHeight="26">  
                            <ContentPresenter x:Name="Icon" Margin="4,0,0,0" VerticalAlignment="Center" Content="{TemplateBinding Icon}" /> 
                            <Path x:Name="GlyphPanel" Fill="{TemplateBinding Foreground}" Margin="4,0,0,0" Visibility="Collapsed" 
                                  VerticalAlignment="Center" 
                                  Data="M 0,5.1 L 1.7,5.2 L 3.4,7.1 L 8,0.4 L 9.2,0 L 3.3,10.8 Z" /> 
                              
                            <ContentPresenter x:Name="Content" Content="{TemplateBinding Header}" 
                                              ContentTemplate="{TemplateBinding HeaderTemplate}" Margin="8,2,16,0" 
                                              Cursor="{TemplateBinding Cursor}" 
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> 
                        </telerik:RadDockPanel> 
                          
                        <Rectangle x:Name="DisabledBox" Fill="{StaticResource DefaultDisabledBrush}" Visibility="Collapsed" IsHitTestVisible="False" /> 
                    </Grid> 
                </ControlTemplate> 
     
                <!-- TopLevelHeader --> 
                <ControlTemplate x:Key="TopLevelHeaderTemplate" TargetType="telerikNav:RadMenuItem">  
                    <Grid x:Name="RootElement" Background="Transparent">  
                        <VisualStateManager.VisualStateGroups> 
                            <VisualStateGroup x:Name="CommonStateGroup">  
     
                                <VisualState x:Name="Highlighted">  
                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Bg" Storyboard.TargetProperty="Fill" Duration="0">  
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SelectedBrush}" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
     
                                <VisualState x:Name="Focused">  
                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Bg" Storyboard.TargetProperty="Fill" Duration="0">  
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SelectedBrush}" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
     
                                <VisualState x:Name="Disabled">  
                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="DisabledBox" Storyboard.TargetProperty="Visibility" Duration="0">  
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Visible}" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
     
                                <VisualState x:Name="Normal" /> 
     
                            </VisualStateGroup> 
                            <VisualStateGroup x:Name="CheckStateGroup">  
     
                                <VisualState x:Name="Checked">  
                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Icon" Storyboard.TargetProperty="Visibility" Duration="0">  
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Collapsed}" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                        <ObjectAnimationUsingKeyFrames  Storyboard.TargetName="GlyphPanel" Storyboard.TargetProperty="Visibility" Duration="0">  
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Visible}" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
     
                                <VisualState x:Name="Unchecked" /> 
     
                                <VisualState x:Name="HideIcon">  
                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Icon" Storyboard.TargetProperty="Visibility" Duration="0">  
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Collapsed}" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
     
                            </VisualStateGroup> 
                        </VisualStateManager.VisualStateGroups> 
                          
                        <Rectangle x:Name="Bg" RadiusX="12" RadiusY="12"    
                                   Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" /> 
                        <telerik:RadDockPanel MinHeight="26">  
                            <ContentPresenter x:Name="Icon" Margin="4,0,0,0" VerticalAlignment="Center" Content="{TemplateBinding Icon}" /> 
                            <Path x:Name="GlyphPanel"   
                                  Fill="{TemplateBinding Foreground}"   
                                  Margin="4,0,0,0" Visibility="Collapsed" VerticalAlignment="Center" 
                                  Data="M 0,5.1 L 1.7,5.2 L 3.4,7.1 L 8,0.4 L 9.2,0 L 3.3,10.8 Z" /> 
                            <ContentPresenter x:Name="Content" Content="{TemplateBinding Header}" 
                                              ContentTemplate="{TemplateBinding HeaderTemplate}"   
                                              Margin="8,2,16,0" 
                                              Cursor="{TemplateBinding Cursor}" 
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> 
                        </telerik:RadDockPanel> 
                        <Popup x:Name="PART_Popup">  
                            <Border BorderBrush="{StaticResource RadMenu_PopupShadowBorder2}" 
                                    BorderThickness="1,0,1,1">  
                                <Border BorderBrush="{StaticResource RadMenu_PopupShadowBorder1}" 
                                        BorderThickness="1,0,1,1">  
                                    <Border Background="{StaticResource ContentBackgroundBrush}" 
                                            BorderBrush="{StaticResource BorderBorderBrush}" 
                                            BorderThickness="1">  
                                        <Grid> 
                                            <Rectangle Margin="24,0,0,0" Width="1" 
                                                       Fill="{StaticResource SeparatorLine1}" 
                                                       HorizontalAlignment="Left" /> 
                                            <Rectangle Margin="25,0,0,0" Width="1" 
                                                       Fill="{StaticResource SeparatorLine2}" 
                                                       HorizontalAlignment="Left" /> 
                                            <ItemsPresenter /> 
                                        </Grid> 
                                    </Border> 
                                </Border> 
                            </Border> 
                        </Popup> 
                        <Rectangle x:Name="DisabledBox" Fill="{StaticResource DefaultDisabledBrush}" 
                                   Visibility="Collapsed" IsHitTestVisible="False" /> 
                    </Grid> 
                </ControlTemplate> 
     
                <!-- SubMenuItem --> 
                <ControlTemplate x:Key="SubMenuItemTemplate" TargetType="telerikNav:RadMenuItem">  
                    <Grid x:Name="RootElement" Background="Transparent">  
     
                        <VisualStateManager.VisualStateGroups> 
                            <VisualStateGroup x:Name="CommonStateGroup">  
     
                                <VisualState x:Name="Highlighted">  
                                    <Storyboard> 
                                        <DoubleAnimation Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Opacity" To="0.5" Duration="0" /> 
                                    </Storyboard> 
                                </VisualState> 
     
                                <VisualState x:Name="Disabled">  
                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="DisabledBox" Storyboard.TargetProperty="Visibility" Duration="0">  
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Visible}" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
     
                                <VisualState x:Name="Normal">  
                                    <Storyboard> 
                                        <DoubleAnimation Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.25" /> 
                                    </Storyboard> 
                                </VisualState> 
     
                            </VisualStateGroup> 
     
                            <VisualStateGroup x:Name="CheckStateGroup">  
     
                                <VisualState x:Name="Checked">  
                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Icon" Storyboard.TargetProperty="Visibility" Duration="0">  
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Collapsed}" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphPanel" Storyboard.TargetProperty="Visibility" Duration="0">  
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Visible}" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
     
                                <VisualState x:Name="Unchecked" /> 
     
                                <VisualState x:Name="HideIcon">  
                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Icon" Storyboard.TargetProperty="Visibility" Duration="0">  
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Collapsed}" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
     
                            </VisualStateGroup> 
                        </VisualStateManager.VisualStateGroups> 
     
                        <Rectangle x:Name="Bg"   
                                   RadiusX="12" 
                                   RadiusY="12" 
                                   Fill="{TemplateBinding Background}" 
                                   Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" /> 
                        <Rectangle x:Name="InnerBorder"   
                                   RadiusX="12" 
                                   RadiusY="12" 
                                   Fill="{StaticResource MouseOverBrush}"   
                                   Opacity="0" /> 
                        <Grid MinHeight="24">  
                            <Grid.ColumnDefinitions> 
                                <ColumnDefinition MinWidth="24" Width="Auto" /> 
                                <ColumnDefinition Width="4" /> 
                                <ColumnDefinition Width="*" /> 
                                <ColumnDefinition Width="37" /> 
                                <ColumnDefinition Width="Auto" /> 
                                <ColumnDefinition Width="17" /> 
                            </Grid.ColumnDefinitions> 
                            <ContentPresenter x:Name="Icon" Margin="1,0,0,0" VerticalAlignment="Center" 
                                              Content="{TemplateBinding Icon}" /> 
                            <Path x:Name="GlyphPanel"   
                                  Fill="Red"   
                                  Margin="1,0,0,0" 
                                  Visibility="Collapsed" 
                                  Data="M 0,5.1 L 1.7,5.2 L 3.4,7.1 L 8,0.4 L 9.2,0 L 3.3,10.8 Z" Width="9" 
                                  Height="11" /> 
     
                            <ContentPresenter x:Name="Content" Grid.Column="2" 
                                              Content="{TemplateBinding Header}" 
                                              ContentTemplate="{TemplateBinding HeaderTemplate}" 
                                              Margin="{TemplateBinding Padding}" Cursor="{TemplateBinding Cursor}" 
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> 
                        </Grid> 
                        <Rectangle x:Name="DisabledBox" Fill="{StaticResource DefaultDisabledBrush}" Visibility="Collapsed" IsHitTestVisible="False" /> 
                    </Grid> 
                </ControlTemplate> 
     
                <!-- SubMenuHeader --> 
                <ControlTemplate x:Key="SubMenuHeaderTemplate" TargetType="telerikNav:RadMenuItem">  
                    <Grid x:Name="RootElement" Background="Transparent">  
     
                        <VisualStateManager.VisualStateGroups> 
                            <VisualStateGroup x:Name="CommonStateGroup">  
     
                                <VisualState x:Name="Highlighted">  
                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="InnerBorder">  
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0.1" Value="{StaticResource SelectedBrush}" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
     
                                <VisualState x:Name="Disabled">  
                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="DisabledBox" Storyboard.TargetProperty="Visibility" Duration="0">  
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Visible}" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
     
                                <VisualState x:Name="Normal">  
                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="InnerBorder">  
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0.1" Value="Transparent" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
     
                            </VisualStateGroup> 
     
                            <VisualStateGroup x:Name="CheckStateGroup">  
     
                                <VisualState x:Name="Checked">  
                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Icon" Storyboard.TargetProperty="Visibility" Duration="0">  
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Collapsed}" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphPanel" Storyboard.TargetProperty="Visibility" Duration="0">  
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Visible}" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
     
                                <VisualState x:Name="Unchecked" /> 
     
                                <VisualState x:Name="HideIcon">  
                                    <Storyboard> 
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Icon" Storyboard.TargetProperty="Visibility" Duration="0">  
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Collapsed}" /> 
                                        </ObjectAnimationUsingKeyFrames> 
                                    </Storyboard> 
                                </VisualState> 
     
                            </VisualStateGroup> 
                        </VisualStateManager.VisualStateGroups> 
     
                        <Rectangle x:Name="Bg" RadiusX="12"   
                                   RadiusY="12" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" /> 
                        <Rectangle x:Name="InnerBorder" RadiusX="12" 
                                   RadiusY="12" Fill="Transparent"/>  
                        <Grid MinHeight="24">  
                            <Grid.ColumnDefinitions> 
                                <ColumnDefinition MinWidth="24" Width="Auto" /> 
                                <ColumnDefinition Width="4" /> 
                                <ColumnDefinition Width="*" /> 
                                <ColumnDefinition Width="37" /> 
                                <ColumnDefinition Width="Auto" /> 
                                <ColumnDefinition Width="17" /> 
                            </Grid.ColumnDefinitions> 
                            <ContentPresenter x:Name="Icon" Margin="1,0,0,0" VerticalAlignment="Center" Content="{TemplateBinding Icon}" /> 
                            <Path x:Name="GlyphPanel" Fill="{TemplateBinding Foreground}" Margin="1,0,0,0" 
                                  Width="9" Height="11" Visibility="Collapsed" 
                                  Data="M 0,5.1 L 1.7,5.2 L 3.4,7.1 L 8,0.4 L 9.2,0 L 3.3,10.8 Z" /> 
     
                            <ContentPresenter x:Name="Content" Grid.Column="2" 
                                              Content="{TemplateBinding Header}" 
                                              ContentTemplate="{TemplateBinding HeaderTemplate}" 
                                              Margin="{TemplateBinding Padding}" Cursor="{TemplateBinding Cursor}" 
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> 
                            <Path Grid.Column="5" VerticalAlignment="Center" Margin="1,0,0,0" 
                                  Fill="{TemplateBinding Foreground}" Data="M 0,0 L 4,3.5 L 0,7 Z" Width="9" /> 
                        </Grid> 
                        <Popup x:Name="PART_Popup" VerticalOffset="-1" HorizontalOffset="-3">  
                            <Border BorderBrush="{StaticResource RadMenu_PopupShadowBorder2}" 
                                    BorderThickness="1,0,1,1">  
                                <Border BorderBrush="{StaticResource RadMenu_PopupShadowBorder1}" 
                                        BorderThickness="1,0,1,1">  
                                    <Border Background="{StaticResource ContentBackgroundBrush}" 
                                            BorderBrush="{StaticResource BorderBorderBrush}" 
                                            BorderThickness="1">  
                                        <Grid> 
                                            <Rectangle Margin="24,0,0,0" Width="1" 
                                                       Fill="{StaticResource SeparatorLine1}" 
                                                       HorizontalAlignment="Left" /> 
                                            <Rectangle Margin="25,0,0,0" Width="1" 
                                                       Fill="{StaticResource SeparatorLine2}" 
                                                       HorizontalAlignment="Left" /> 
                                            <ItemsPresenter /> 
                                        </Grid> 
                                    </Border> 
                                </Border> 
                            </Border> 
                        </Popup> 
                        <Rectangle x:Name="DisabledBox" Fill="{StaticResource DefaultDisabledBrush}" 
                                   Visibility="Collapsed" IsHitTestVisible="False" /> 
                    </Grid> 
                </ControlTemplate> 
     
                <!-- RadMenuItem --> 
                <Style x:Key="ContextMenuItemDefaultStyle" TargetType="telerikNav:RadMenuItem">  
                    <Setter Property="TopLevelHeaderTemplateKey" Value="{StaticResource TopLevelHeaderTemplate}" /> 
                    <Setter Property="TopLevelItemTemplateKey" Value="{StaticResource TopLevelItemTemplate}" /> 
                    <Setter Property="SubmenuHeaderTemplateKey" Value="{StaticResource SubMenuHeaderTemplate}" /> 
                    <Setter Property="SubmenuItemTemplateKey" Value="{StaticResource SubMenuItemTemplate}" /> 
                    <Setter Property="Template" Value="{StaticResource SubMenuItemTemplate}" /> 
                    <Setter Property="HorizontalContentAlignment" Value="Left" /> 
                    <Setter Property="VerticalContentAlignment" Value="Center" /> 
                </Style> 
     
                <Style x:Key="ContextMenuDefaultStyle" TargetType="telerikNav:RadContextMenu">  
                    <Setter Property="Background" Value="{StaticResource BorderVerticalLinearBackground}" /> 
                    <Setter Property="VerticalContentAlignment" Value="Center" /> 
                    <Setter Property="BorderThickness" Value="1" /> 
                    <Setter Property="BorderBrush" Value="{StaticResource BorderBorderBrush}" /> 
                    <Setter Property="Opacity" Value="0.8" /> 
                    <Setter Property="Template">  
                        <Setter.Value> 
                            <ControlTemplate TargetType="telerikNav:RadContextMenu">  
                                <Border BorderThickness="1,0,1,1" 
                                        Opacity="{TemplateBinding Opacity}">  
                                    <Border BorderThickness="1,0,1,1">  
                                        <Border Background="{TemplateBinding Background}" 
                                                CornerRadius="12" 
                                                BorderBrush="{TemplateBinding BorderBrush}" 
                                                BorderThickness="{TemplateBinding BorderThickness}" 
                                                Padding="10">  
                                            <Grid> 
                                                <Rectangle Margin="24,0,0,0"   
                                                           Width="1" 
                                                           Fill="{StaticResource SeparatorLine1}" 
                                                           HorizontalAlignment="Left" /> 
                                                <Rectangle Margin="25,0,0,0"   
                                                           Width="1" 
                                                           Fill="{StaticResource SeparatorLine2}" 
                                                           HorizontalAlignment="Left" /> 
                                                <ItemsPresenter Margin="{TemplateBinding Padding}" /> 
                                            </Grid> 
                                        </Border> 
                                    </Border> 
                                </Border> 
                            </ControlTemplate> 
                        </Setter.Value> 
                    </Setter> 
                </Style> 

    Do you have any idea?
  2. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 21 Jan 2009 Link to this post

    Hello Steffen,

    I was not able to create a working project from the source that you provide. Please open a support ticket and attach simple project so I can investigate it.
    I was wondering why you attach to Click and change the IsChecked property?
    There is IsCheckable property which when true inverts IsChecked property on MouseLeftButtonDown.

    Greetings,
    Hristo
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. DevCraft banner
  4. Steffen
    Steffen avatar
    8 posts
    Member since:
    Jan 2009

    Posted 21 Jan 2009 Link to this post

    Hello Hristo,

    About the IsChecked property set in code behind: I have an enum with 5 values: OK, NOK, PartialOK, NotNeeded, Unchecked.
    Each member of the enum must be an item of the contextmenu...  This contextmenu can be opened on a Border representing a  SecureParty and user can change the value of the enum by clicking on the ContextMenu so: 1) I must check the current value of the SecureParty in the ContextMenu. 2) If user click on another Item, I update the SecureParty and then I must uncheck other menu items.

    Thank for you help... I'll send a Ticket with my Silverlight project: (Ticket ID is 186006).

    Greetings,

    Xavier.
Back to Top