Click here to Skip to main content
14,973,838 members
Home / Discussions / WPF
   

WPF

 
QuestionWPF Listbox - How to keep the scrolling from changing the property? Pin
dbrenth6-Sep-16 3:49
Memberdbrenth6-Sep-16 3:49 
QuestionDoes width and height need to be explicitly defined in ControlTemplate? Pin
James J M5-Sep-16 6:35
MemberJames J M5-Sep-16 6:35 
QuestionComboBox - SelectedValue and SelectedItem Pin
Mycroft Holmes31-Aug-16 14:48
professionalMycroft Holmes31-Aug-16 14:48 
QuestionWPF: Reading a document's bytes into a stream to store in a database table. Pin
holdorf31-Aug-16 10:47
Memberholdorf31-Aug-16 10:47 
AnswerRe: WPF: Reading a document's bytes into a stream to store in a database table. Pin
Pete O'Hanlon31-Aug-16 11:16
mvePete O'Hanlon31-Aug-16 11:16 
QuestionUWP. How to find out size of uwp Windows.Storage element? Pin
wind te26-Aug-16 22:42
Memberwind te26-Aug-16 22:42 
AnswerRe: UWP. How to find out size of uwp Windows.Storage element? Pin
Pete O'Hanlon31-Aug-16 12:29
mvePete O'Hanlon31-Aug-16 12:29 
QuestionClosing a static WPF Window from other Window instances. Pin
holdorf23-Aug-16 3:23
Memberholdorf23-Aug-16 3:23 
My problem is very difficult to describe but this is what I am trying to do. See all code below. What I have is a parent WPF Window that has a child View, created as a UserControl, added to the parent Window in it's markup. Now the problem is this. When a row, on the child UserControl View's GridView is clicked I want to close the child view's parent (Window) then navigate to an entirely new Window and open it. When I click the row I get the error 'Invalid cast exception". See below:

Static class defined in the same namespace:

public static class closeWindow
{
    public static object WinObject;

    public static void CloseParent()
    {
        using ((System.IDisposable)closeWindow.WinObject)
        {
            ((Window)WinObject).Close();
        }
    }
}


Markup in the XAML parent Window page:

<v:savedraftview>


public partial class SavedDrafts : Window
{
    public SavedDrafts()
    {
        InitializeComponent();

        LoadMe();

    }

    public void loadMe()
    {
        closeWindow.WinObject = this;
    }

}


Code in the Event contained the child view.

// From me the child view, open a new window and close my parent Window.//


                Intake1 window = new Intake1();
                window.Show();

                closeWindow.CloseParent();


modified 23-Aug-16 9:38am.

AnswerRe: Closing a static WPF Window from other Window instances. Pin
holdorf23-Aug-16 4:09
Memberholdorf23-Aug-16 4:09 
AnswerRe: Closing a static WPF Window from other Window instances. Pin
Richard Deeming23-Aug-16 4:27
mveRichard Deeming23-Aug-16 4:27 
QuestionCommunicating Between ViewModels Pin
JBHowl18-Aug-16 2:12
MemberJBHowl18-Aug-16 2:12 
AnswerRe: Communicating Between ViewModels Pin
Pete O'Hanlon18-Aug-16 3:24
mvePete O'Hanlon18-Aug-16 3:24 
SuggestionRe: Communicating Between ViewModels Pin
AlexaGrey8628-Aug-16 2:43
MemberAlexaGrey8628-Aug-16 2:43 
AnswerRe: Communicating Between ViewModels Pin
Kenneth Haugland18-Aug-16 5:07
professionalKenneth Haugland18-Aug-16 5:07 
QuestionWPF / Prism: Design decision with different views for same region Pin
SutterA17-Aug-16 2:12
MemberSutterA17-Aug-16 2:12 
AnswerRe: WPF / Prism: Design decision with different views for same region Pin
Gerry Schmitz17-Aug-16 6:22
mveGerry Schmitz17-Aug-16 6:22 
GeneralRe: WPF / Prism: Design decision with different views for same region Pin
SutterA18-Aug-16 20:05
MemberSutterA18-Aug-16 20:05 
GeneralRe: WPF / Prism: Design decision with different views for same region Pin
Gerry Schmitz19-Aug-16 4:44
mveGerry Schmitz19-Aug-16 4:44 
AnswerRe: WPF / Prism: Design decision with different views for same region Pin
Mycroft Holmes17-Aug-16 14:31
professionalMycroft Holmes17-Aug-16 14:31 
AnswerRe: WPF / Prism: Design decision with different views for same region Pin
Pete O'Hanlon19-Aug-16 0:31
mvePete O'Hanlon19-Aug-16 0:31 
QuestionSignalR Project Problem Revisited Pin
Kevin Marois14-Aug-16 17:58
professionalKevin Marois14-Aug-16 17:58 
QuestionBasic WPF binding to collection in combobox. Pin
wind te10-Aug-16 11:48
Memberwind te10-Aug-16 11:48 
AnswerRe: Basic WPF binding to collection in combobox. Pin
Pete O'Hanlon10-Aug-16 12:20
mvePete O'Hanlon10-Aug-16 12:20 
GeneralRe: Basic WPF binding to collection in combobox. Pin
wind te10-Aug-16 18:41
Memberwind te10-Aug-16 18:41 
GeneralRe: Basic WPF binding to collection in combobox. Pin
Pete O'Hanlon10-Aug-16 21:21
mvePete O'Hanlon10-Aug-16 21:21 

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.