Reputation: 79
Is there any way to write the ShowDialog window method (e.g. driversWindow.ShowDialog();) via Xaml?
I want that pressing a button will open a dialog window define in the Xaml code
Thanks
Eran
Upvotes: 0
Views: 2268
Reputation: 17272
You can use <x:Code>
:
<Button Content="OK" Click="Button_Click"/>
<x:Code>
private void Button_Click(object sender,RoutedEventArgs e)
{
MessageBox.Show("Hello");
}
</x:Code>
It is pretty messy to mix C# and XAML like this though.
The standard way to do this are commands.
Upvotes: 1
Reputation: 5552
In general if you want to call a method on an object in XAML you wrap the object with ObjectDataProvider and then use MethodName property to call the method.
http://msdn.microsoft.com/en-us/library/system.windows.data.objectdataprovider.aspx
Upvotes: 0