This is the little bit sample, I hope this will be helpful to you.
You can simply update the click event of button code with your menuitem click event.
MainWindow.
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Button Content="Button" HorizontalAlignment="Left" Margin="228,80,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>
<Label Content="Label" Name="lblXmlFileName" HorizontalAlignment="Left" Margin="57,78,0,0" VerticalAlignment="Top" Width="144"/>
<StackPanel x:Name="stackpanel1">
<StackPanel.Resources>
<XmlDataProvider x:Name="provider" x:Key="provider1">
</XmlDataProvider>
</StackPanel.Resources>
</StackPanel>
</Grid>
Code Behind:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
// update validations as per your requirements...
var dialog = new OpenFileDialog();
dialog.Filter = "XML Files|*.xml";
if (dialog.ShowDialog() == true)
{
lblXmlFileName.Content = dialog.FileName.ToString();
var provider1 = (XmlDataProvider) stackpanel1.Resources["provider1"];
if(provider1 != null)
provider1.Source = new Uri(dialog.FileName, UriKind.Absolute);
}
}
}