1

I am using WpfNotifyIcon, I have declared it as a resource like this:

<Application x:Class="NotifyIconScratchPad2.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:tb="http://www.hardcodet.net/taskbar" 
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <tb:TaskbarIcon x:Key="MyNotifyIcon" IconSource="Icons/stopwatch_start.ico" ToolTipText="Hello world" >
            <tb:TaskbarIcon.TrayToolTip>
                <TextBlock x:Name="ChangeThis" Text="Hello world"  />
            </tb:TaskbarIcon.TrayToolTip>
            </tb:TaskbarIcon>
    </Application.Resources>
</Application>

To use this, I declare it in MainWindow.xaml.cs:

    public TaskbarIcon tb;
    public Window1 myWindow;
    public MainWindow()
    {
        InitializeComponent();
        tb = (TaskbarIcon) FindResource("MyNotifyIcon");
    }

How can I access the textbox ChangeThis from another window?

stirredo
  • 2,297
  • 3
  • 19
  • 23
  • I couldn't find the answer. I ended up declaring the notifyIcon in the Window itself and then accessing the TextBlock from there. – stirredo Apr 03 '13 at 19:32

2 Answers2

0

The ultimate answer is setting up an event to do so.

The Model-View-View Model pattern is a good way to accomplish this.

Basically, you have a class that implements the INotifyPropertyChanged interface and a two-way data binding between both text boxes and the data source.

Christopher Stevenson
  • 2,843
  • 20
  • 25
0

you can use FindName method:

 TextBox txtToChange= tb.FindName("txt_ChangeThis") as TextBox;
user1064519
  • 2,180
  • 12
  • 13
  • When I do `TextBlock textBlock = tb.FindName("ChangeThis") as TextBlock;`, I am getting `null` back. It isn't working. Anything else I can do? – stirredo Apr 03 '13 at 16:45