Click here to Skip to main content
15,898,374 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# Newbie. Need help on coding a errorcheck Pin
Setasigge4-Jun-15 22:01
Setasigge4-Jun-15 22:01 
GeneralRe: C# Newbie. Need help on coding a errorcheck Pin
Richard MacCutchan5-Jun-15 0:27
mveRichard MacCutchan5-Jun-15 0:27 
QuestionImplementing PocketSphinx in C# Pin
Member 105130663-Jun-15 21:14
Member 105130663-Jun-15 21:14 
AnswerREPOST Pin
Richard Deeming3-Jun-15 21:32
mveRichard Deeming3-Jun-15 21:32 
GeneralRe: REPOST Pin
Member 105130663-Jun-15 21:54
Member 105130663-Jun-15 21:54 
SuggestionRe: Implementing PocketSphinx in C# Pin
Richard MacCutchan3-Jun-15 21:35
mveRichard MacCutchan3-Jun-15 21:35 
AnswerRe: Implementing PocketSphinx in C# Pin
Simon_Whale3-Jun-15 22:25
Simon_Whale3-Jun-15 22:25 
AnswerRe: Implementing PocketSphinx in C# Pin
Pete O'Hanlon3-Jun-15 22:31
mvePete O'Hanlon3-Jun-15 22:31 
QuestionFresher problem for getting job in asp.net? Pin
Andyweil223-Jun-15 16:58
Andyweil223-Jun-15 16:58 
AnswerRe: Fresher problem for getting job in asp.net? Pin
Richard MacCutchan3-Jun-15 21:40
mveRichard MacCutchan3-Jun-15 21:40 
AnswerRe: Fresher problem for getting job in asp.net? Pin
OriginalGriff3-Jun-15 22:30
mveOriginalGriff3-Jun-15 22:30 
QuestionHow to not display the a row based on a condition. Pin
Norris Chappell3-Jun-15 14:39
Norris Chappell3-Jun-15 14:39 
AnswerRe: How to not display the a row based on a condition. Pin
PIEBALDconsult3-Jun-15 14:47
mvePIEBALDconsult3-Jun-15 14:47 
GeneralRe: How to not display the a row based on a condition. Pin
Norris Chappell4-Jun-15 4:21
Norris Chappell4-Jun-15 4:21 
AnswerRe: How to not display the a row based on a condition. Pin
Mathi Mani3-Jun-15 15:54
Mathi Mani3-Jun-15 15:54 
GeneralRe: How to not display the a row based on a condition. Pin
Norris Chappell4-Jun-15 3:54
Norris Chappell4-Jun-15 3:54 
QuestionRe: How to not display the a row based on a condition. Pin
Agent__0073-Jun-15 18:41
professionalAgent__0073-Jun-15 18:41 
AnswerRe: How to not display the a row based on a condition. Pin
Agent__0077-Jun-15 18:46
professionalAgent__0077-Jun-15 18:46 
GeneralRe: How to not display the a row based on a condition. Pin
Norris Chappell8-Jun-15 5:47
Norris Chappell8-Jun-15 5:47 
GeneralRe: How to not display the a row based on a condition. Pin
Richard Deeming8-Jun-15 6:49
mveRichard Deeming8-Jun-15 6:49 
GeneralRe: How to not display the a row based on a condition. Pin
Norris Chappell8-Jun-15 8:34
Norris Chappell8-Jun-15 8:34 
QuestionClass Hierarchy Design Question Pin
Kevin Marois3-Jun-15 12:44
professionalKevin Marois3-Jun-15 12:44 
I'm working on a WPF/C# app.

Background

First, all my user controls in WPF inherit from a base control:
public interface IControl
{
    void Load();
    void Cleanup();
}

and
public abstract class _UserControlBase : UserControl, INotifyPropertyChanged, IControl
{
    public new abstract bool IsEnabled { get; set; }

    public abstract void Load();
    public abstract void Cleanup();

    public event PropertyChangedEventHandler PropertyChanged;
    protected void RaisePropertyChanged(string propertyName)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}

Next, I created a control called ConnectionView which inherits from both _UserControlBase and its own interface:
public interface IConnectionView
{
    event EventHandler<ConnectedToDeviceEventArgs> ConnectedToDevice;
}

and
public partial class ConnectionView : _UserControlBase, IConnectionView
{
    #region Event Declations
    public event EventHandler<ConnectedToDeviceEventArgs> ConnectedToDevice;
    #endregion

 .
 .
 .
}

Finally, in my MainWindowView I have a content presenter bound to the property CurrentView and it's loaded like this:
public class MainWindowViewModel : _ViewModelBase
{
    private IControl _CurrentView;
    public IControl CurrentView
    {
        get { return _CurrentView; }
        set
        {
            if (_CurrentView != value)
            {
                _CurrentView = value;
                RaisePropertyChanged("CurrentView");
            }
        }
    }

    public MainWindowViewModel()
    {
        loadView(AppMode.Discover);
    }

    private void loadView(AppMode mode)
    {
        if (CurrentView != null)
        {
            CurrentView.Cleanup();
        }

        switch (mode)
        {
            case AppMode.Connected:
                break;

            case AppMode.Discover:
                CurrentView = new ConnectionView();
                CurrentView.Load();
                break;
        }
    }
}

The Problem

Since the CurrentView is based off _UserControlBase, the ConnectedToDevice event isn't available.

How do I subscribe to the ConnectionView's ConnectedToDevice event in the main window?
If it's not broken, fix it until it is

AnswerRe: Class Hierarchy Design Question Pin
Richard Deeming3-Jun-15 21:40
mveRichard Deeming3-Jun-15 21:40 
GeneralRe: Class Hierarchy Design Question Pin
Kevin Marois4-Jun-15 4:27
professionalKevin Marois4-Jun-15 4:27 
QuestionC# PDF Printing Pin
El Developer3-Jun-15 4:54
El Developer3-Jun-15 4:54 

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.