Where would the responsibility to handle this event be placed?
I have a NavigationBar.cs user control. I also have NavigationItem.cs user control.
Here's the code for both:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Uboldi.CustomUI
{
public partial class NavigationBar : UserControl
{
public NavigationBar()
{
InitializeComponent();
}
public List<NavigationItem> NavigationItems { private get; set; }
public NavigationItem SelectedItem { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Uboldi.CustomUI
{
public partial class NavigationItem : UserControl
{
public NavigationItem()
{
InitializeComponent();
}
private Image _picture = null;
public Image Picture
{
get
{
return _picture;
}
set
{
_picture = value;
ptbIcon.Image = _picture;
}
}
private string _content = null;
public string Content
{
get
{
return _content;
}
set
{
_content = value;
lblDisplayText.Text = _content;
}
}
}
}
I only want a single NavigationItem in the navigationbar to be 'selected' at any given time.
When an item is selected a different color will be given to it.
My question is, where should I program this code? In the bar, or is it something a button should do and have the bar just invoke that SetYourSelfAsSelected() method?
Thanks.
I would implement this functionality in the NavigationBar
for the following reason: Some other developer could use your NavigationItem
s in a different context where no active items are marked or marked any different. Or one wants to overload the NavigationBar
to implement another behaviour for active items.
精彩评论