Accessing XAML object in codebehind(WPF)
I'm creating object in XAML like this
<Window.Resources>
<local:DataReceiver x:Key="request">
</l开发者_如何学Cocal:DataReceiver>
</Window.Resources>
how can I call this objects method from codebehind?
var dataReceiver = (DataReceiver)FindResource("request");
...
DataReceiver request = this.TryFindResource("request") as DataReceiver;
if (request != null)
{
// your code here
}
精彩评论