Click here to Skip to main content
15,885,767 members
Home / Discussions / C#
   

C#

 
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);
}
}

}

---------------------------------------------------------------------------------------
AnswerRe: C# WPF MenuItem Control not working Pin
Mycroft Holmes15-Nov-20 11:03
professionalMycroft Holmes15-Nov-20 11:03 
GeneralRe: C# WPF MenuItem Control not working Pin
Member 783087417-Nov-20 14:51
Member 783087417-Nov-20 14:51 
QuestionHow to group an array list, within a list of records, Linq GroupBy Pin
jkirkerx14-Nov-20 13:29
professionaljkirkerx14-Nov-20 13:29 
AnswerRe: How to group an array list, within a list of records, Linq GroupBy Pin
Gerry Schmitz14-Nov-20 22:31
mveGerry Schmitz14-Nov-20 22:31 
QuestionA proper way to return a list (Xamarin, CollectionView, Realm) Pin
Member 1499286214-Nov-20 9:10
Member 1499286214-Nov-20 9:10 
SuggestionRe: A proper way to return a list (Xamarin, CollectionView, Realm) Pin
Richard MacCutchan14-Nov-20 6:07
mveRichard MacCutchan14-Nov-20 6:07 
GeneralRe: A proper way to return a list (Xamarin, CollectionView, Realm) Pin
Member 1499286214-Nov-20 9:10
Member 1499286214-Nov-20 9:10 
GeneralRe: A proper way to return a list (Xamarin, CollectionView, Realm) Pin
OriginalGriff14-Nov-20 9:16
mveOriginalGriff14-Nov-20 9:16 
AnswerRe: A proper way to return a list (Xamarin, CollectionView, Realm) Pin
Mycroft Holmes14-Nov-20 12:18
professionalMycroft Holmes14-Nov-20 12:18 
GeneralRe: A proper way to return a list (Xamarin, CollectionView, Realm) Pin
Member 1499286216-Nov-20 8:17
Member 1499286216-Nov-20 8:17 
QuestionHow to selected value of a dropbox column of a DataGridView programmatically? Pin
Alex Dunlop13-Nov-20 0:41
Alex Dunlop13-Nov-20 0:41 
AnswerRe: How to selected value of a dropbox column of a DataGridView programmatically? Pin
Richard MacCutchan13-Nov-20 1:55
mveRichard MacCutchan13-Nov-20 1:55 
GeneralRe: How to selected value of a dropbox column of a DataGridView programmatically? Pin
Richard Deeming13-Nov-20 2:06
mveRichard Deeming13-Nov-20 2:06 
GeneralRe: How to selected value of a dropbox column of a DataGridView programmatically? Pin
Richard MacCutchan13-Nov-20 2:16
mveRichard MacCutchan13-Nov-20 2:16 
GeneralRe: How to selected value of a dropbox column of a DataGridView programmatically? Pin
Alex Dunlop13-Nov-20 3:09
Alex Dunlop13-Nov-20 3:09 
AnswerRe: How to selected value of a dropbox column of a DataGridView programmatically? Pin
Gerry Schmitz13-Nov-20 4:10
mveGerry Schmitz13-Nov-20 4:10 
QuestionCommented code in c# forms does it affect the performance Pin
Sachin Kulkarni B12-Nov-20 4:50
Sachin Kulkarni B12-Nov-20 4:50 

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.