---
title: "How get control from non-window class in WPF?"  
description: "How get control from non-window class in WPF?"  
author: "Anonymous User"  
published: 2013-07-19  
updated: 2013-07-19  
canonical: https://www.mindstick.com/forum/1327/how-get-control-from-non-window-class-in-wpf  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# How get control from non-window class in WPF?

Application.Current.MainWindow. ?

## Replies

### Reply by Vijay Shukla

If your control is in the main window of your application, you most likely need to cast it to the appropriate type. For example, if your "main window" is named Window1 (default naming), you could do:

Window1 myWindow = Application.Current.MainWindow as Window1;

```
if (myWindow != null){     Button myButton =
myWindow.button1; // Use your control here...    
myButton.IsEnabled = true; // Do something with the control here...}
```


---

Original Source: https://www.mindstick.com/forum/1327/how-get-control-from-non-window-class-in-wpf

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
