Click here to Skip to main content
15,892,298 members
Home / Discussions / C#
   

C#

 
GeneralRe: Changing the properties of multiple labels in some kind of loop? Pin
OriginalGriff16-Nov-20 5:27
mveOriginalGriff16-Nov-20 5:27 
GeneralRe: Changing the properties of multiple labels in some kind of loop? Pin
Ron_UK16-Nov-20 8:39
Ron_UK16-Nov-20 8:39 
GeneralRe: Changing the properties of multiple labels in some kind of loop? Pin
OriginalGriff16-Nov-20 9:29
mveOriginalGriff16-Nov-20 9:29 
AnswerRe: Changing the properties of multiple labels in some kind of loop? Pin
Luc Pattyn16-Nov-20 5:30
sitebuilderLuc Pattyn16-Nov-20 5:30 
GeneralRe: Changing the properties of multiple labels in some kind of loop? Pin
Ron_UK16-Nov-20 5:40
Ron_UK16-Nov-20 5:40 
AnswerRe: Changing the properties of multiple labels in some kind of loop? Pin
Gerry Schmitz16-Nov-20 7:13
mveGerry Schmitz16-Nov-20 7:13 
QuestionHow to make a dll library? Pin
Alex Dunlop16-Nov-20 0:22
Alex Dunlop16-Nov-20 0:22 
AnswerRe: How to make a dll library? Pin
Richard MacCutchan16-Nov-20 0:44
mveRichard MacCutchan16-Nov-20 0:44 
GeneralRe: How to make a dll library? Pin
Alex Dunlop16-Nov-20 0:47
Alex Dunlop16-Nov-20 0:47 
GeneralRe: How to make a dll library? Pin
Richard MacCutchan16-Nov-20 0:51
mveRichard MacCutchan16-Nov-20 0:51 
AnswerRe: How to make a dll library? Pin
OriginalGriff16-Nov-20 0:50
mveOriginalGriff16-Nov-20 0:50 
GeneralRe: How to make a dll library? Pin
Alex Dunlop16-Nov-20 1:51
Alex Dunlop16-Nov-20 1:51 
GeneralRe: How to make a dll library? Pin
OriginalGriff16-Nov-20 2:17
mveOriginalGriff16-Nov-20 2:17 
GeneralRe: How to make a dll library? Pin
Alex Dunlop16-Nov-20 2:25
Alex Dunlop16-Nov-20 2:25 
GeneralRe: How to make a dll library? Pin
OriginalGriff16-Nov-20 2:41
mveOriginalGriff16-Nov-20 2:41 
GeneralRe: How to make a dll library? Pin
Alex Dunlop16-Nov-20 2:48
Alex Dunlop16-Nov-20 2:48 
GeneralRe: How to make a dll library? Pin
OriginalGriff16-Nov-20 2:50
mveOriginalGriff16-Nov-20 2:50 
GeneralRe: How to make a dll library? Pin
Alex Dunlop16-Nov-20 3:09
Alex Dunlop16-Nov-20 3:09 
GeneralRe: How to make a dll library? Pin
OriginalGriff16-Nov-20 3:40
mveOriginalGriff16-Nov-20 3:40 
GeneralRe: How to make a dll library? Pin
Alex Dunlop16-Nov-20 4:15
Alex Dunlop16-Nov-20 4:15 
GeneralRe: How to make a dll library? Pin
OriginalGriff16-Nov-20 4:37
mveOriginalGriff16-Nov-20 4:37 
GeneralMessage Closed Pin
16-Nov-20 5:23
Alex Dunlop16-Nov-20 5:23 
GeneralRe: How to make a dll library? Pin
OriginalGriff16-Nov-20 5:41
mveOriginalGriff16-Nov-20 5:41 
GeneralRe: How to make a dll library? Pin
OriginalGriff16-Nov-20 2:21
mveOriginalGriff16-Nov-20 2:21 
QuestionC# WPF MenuItem Control not working Pin
Member 783087415-Nov-20 9:01
Member 783087415-Nov-20 9:01 
I have been working on this for some time now. Google can only take me so far...
So I thought I'd ask you guys and girls for some help...
----
I have a simple C#, WPF application that I've been playing around with to learn C# and WPF.
The code below is working, but its not displaying my menu items correctly. Here is an example of what it looks like (example A) and what it should look like (example b)
---------------------------------------------------------------------------------------
Example A:
---------------------------------------------------------------------------------------
File | Users | Settings | Tools | Help | Login | Exit | Managers | Window1 | Window2
---------------------------------------------------------------------------------------
Example B:
---------------------------------------------------------------------------------------
File | Users | Settings | Tools | Help Login
Exit | | Managers
| Window1
| Window2
---------------------------------------------------------------------------------------
Exit is a ChildItems \ sub menu items of File
Where as Managers, Window1, Window2 are ChildItems of Tools
---------------------------------------------------------------------------------------

My code below is working to a point
1) For my "mainItem", top level MenuItems, it's pulling them from the database correctly and displaying them correctly

2) For my "childItem", the menu items are pulling correctly from the database, but they are not being assigned or linked to their parent menu item correctly.

This is where I think I need some help from you!

---------------------------------------------------------------------------------------
public void PopulateMenu()
{
// MAIN MENU
Grid.SetRow(mainMenu, 0);
mainMenu.IsMainMenu = true;
mainMenu.Padding = new Thickness(5);
mainMenu.FontSize = 14;
mainMenu.HorizontalAlignment = HorizontalAlignment.Stretch;
mainMenu.VerticalAlignment = VerticalAlignment.Top;

// MENU ITEMSPANEL
mainMenu.ItemsPanel = new ItemsPanelTemplate(
new FrameworkElementFactory(
typeof(DockPanel)));

using (var db = new WorkShopContext())
{

foreach (var m in db.Menus
.Where(p => p.mParentId == 0)
.ToList())
{
// ADD MAIN MENUITEMS
if (!string.IsNullOrEmpty(m.mParentId.ToString()))
{
MenuItem mainItem = new MenuItem();
mainItem.Header = m.mHeader;
mainItem.Tag = m.mTag;
mainItem.Click += MenuItem_Click;

if (m.mHeader == "Login")
{
mainItem.HorizontalAlignment = HorizontalAlignment.Right;
}
mainMenu.Items.Add(mainItem);
}
}

AddChildItems();

}
}

private void AddChildItems()
{
foreach (var c in db.Menus
.Where(p => p.mParentId > 0)
.ToList())
{
if (!string.IsNullOrEmpty(c.mParentId.ToString()))
{
MenuItem childItem = new MenuItem();
childItem.Header = c.mHeader;
childItem.Tag = c.mTag;
childItem.Click += MenuItem_Click;

mainMenu.Items.Add(childItem);
}
}

}

---------------------------------------------------------------------------------------

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.