Click here to Skip to main content
15,888,026 members
Home / Discussions / C#
   

C#

 
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 
AnswerRe: C# PDF Printing Pin
Pete O'Hanlon3-Jun-15 5:01
mvePete O'Hanlon3-Jun-15 5:01 
GeneralRe: C# PDF Printing Pin
El Developer3-Jun-15 5:10
El Developer3-Jun-15 5:10 
GeneralRe: C# PDF Printing Pin
Pete O'Hanlon3-Jun-15 5:14
mvePete O'Hanlon3-Jun-15 5:14 
GeneralRe: C# PDF Printing Pin
El Developer3-Jun-15 5:30
El Developer3-Jun-15 5:30 
GeneralRe: C# PDF Printing Pin
Pete O'Hanlon3-Jun-15 5:56
mvePete O'Hanlon3-Jun-15 5:56 
QuestionStack exchange redis with .NetFramework 4.0 c# Pin
Member 104597132-Jun-15 23:59
Member 104597132-Jun-15 23:59 
AnswerRe: Stack exchange redis with .NetFramework 4.0 c# Pin
Mycroft Holmes3-Jun-15 14:31
professionalMycroft Holmes3-Jun-15 14:31 
GeneralRe: Stack exchange redis with .NetFramework 4.0 c# Pin
Member 104597134-Jun-15 23:21
Member 104597134-Jun-15 23:21 
Questionhow to fill textbox with DGV Column ? Pin
Member 115798702-Jun-15 22:24
Member 115798702-Jun-15 22:24 
AnswerRe: how to fill textbox with DGV Column ? Pin
OriginalGriff2-Jun-15 22:38
mveOriginalGriff2-Jun-15 22:38 
GeneralRe: how to fill textbox with DGV Column ? Pin
Member 115798702-Jun-15 22:45
Member 115798702-Jun-15 22:45 
GeneralRe: how to fill textbox with DGV Column ? Pin
OriginalGriff2-Jun-15 22:52
mveOriginalGriff2-Jun-15 22:52 
GeneralRe: how to fill textbox with DGV Column ? Pin
Member 115798702-Jun-15 23:02
Member 115798702-Jun-15 23:02 
GeneralRe: how to fill textbox with DGV Column ? Pin
OriginalGriff2-Jun-15 23:05
mveOriginalGriff2-Jun-15 23:05 

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.