C
C#2y ago
Kippachu

Making concrete object classes

private void Initialize_NavigationItems()
{
var fooNavigationItem = new NavigationItem
{
Header = "Foo",
Items = new NavigationItemsCollection
{
new()
{
Header = "Foo task 1",
Command = CommandOpenDialog
}
}
};

NavigationItems = new NavigationItemsCollection
{
fooNavigationItem
};
}
private void Initialize_NavigationItems()
{
var fooNavigationItem = new NavigationItem
{
Header = "Foo",
Items = new NavigationItemsCollection
{
new()
{
Header = "Foo task 1",
Command = CommandOpenDialog
}
}
};

NavigationItems = new NavigationItemsCollection
{
fooNavigationItem
};
}
Hello, in this example is how I create my navigation items but my question is, instead of having too much logic in my method, isn't simply better if I create a FooNavigationItem and move the logic in it ? The method would become =>
private void Initialize_NavigationItems()
{
NavigationItems = new NavigationItemsCollection
{
new FooNavigationItem()
};
}
private void Initialize_NavigationItems()
{
NavigationItems = new NavigationItemsCollection
{
new FooNavigationItem()
};
}
Thanks
1 Reply
sibber
sibber2y ago
just do it in xaml if not id keep it as is making a class for each nav item would be messy imo