grammar questions

patrick

Well-known member
Joined
Dec 5, 2021
Messages
311
Programming Experience
1-3
Hello

XAML.xaml:
<Window.Resources>
        <ControlTemplate x:Key="Template" TargetType="MenuItem">
            <Grid HorizontalAlignment="Stretch">               
                    <Lable Name="label">Label</Label>             
            </Grid>
        </ControlTemplate> 
</Window.Resources>   
  
<Grid x:Name="LayoutRoot" >
        <Menu x:Name="Menu">
            <MenuItem Header="File"/>
            <MenuItem Header="Edit" IsSeparator="True" Template="{StaticResource Template}" />           
            <MenuItem Header="View" />         
        </Menu>
</Grid>


menuitem.cs:
using System.Windows.Controls;

namespace UserComponet
{
    public class MenuItem : RadMenuItem
    {
        public MenuItem()
        {
            this.Focusable = False;
        }
    }
}

RadMenuItem.cs:
THIS IS DLL
Public bool IsSeparator { get; set }
Public ControlTemplate SeparatorTemplateKey{ get; set }

viewsource.cs:
protected static MenuItem Separator
{
    get  {   return new MenuItem   {
            IsSeparator = true; //<===  Public bool IsSeparator { get; set }  OF  THE RadMenuItem.cs  File
        }   }
}
protected static MenuItem SeparatorTemplateKey(ControlTemplate key)
{
    get
    {
        return new MenuItem
        {
            SeparatorTemplateKey(key); //<===  Public ControlTemplate SeparatorTemplateKey{ get; set }  OF  THE RadMenuItem.cs  File && ControlTemplate x:Key="Template" OF XAML.xaml File  <===I think the grammar is wrong
        }
    }
}


mainview.cs:
using System.Windows.Controls;
public override ObservableCollection<MenuItem> GetMenu()
{
    var contextmenuitem = new ObservableCollection<MenuItem>(); 
    var eRNode = crateMenuItem("Report");
    eRNode.Items.Add(createMenuItem("Sub"));
  
    contextmenuitem.Add(Separate); <=== ☆☆☆☆☆ Example ☆☆☆☆☆
    ControlTemplate template = new ControlTemplate();
    template.key = "Tamplate";
    contextmenuitem.Add(SeparatorTemplateKey(template)); <===ControlTemplate x:Key="Template" OF XAML.xaml File .... <==I don't know grammar. How do I write code?
    contextmenuitem.Add(eRNode);
}




Plase Help me.....
 
If you can't be bothered to provide a FULL and CLEAR explanation of the problem, you'll find many people unwilling to waste their time trying to work out what it is. A few comments in some code snippets don't cut it.
 
It's hard to help you if you don't tell us with a full and clear explanation of what problem you are trying to solve and what you have tried.

Based on the code you've posted above it's even more confusing to see you post both the declarative XAML, and then also post code that is trying to do it imperatively.
 
Back
Top Bottom