如何向标准XAML元素添加其他属性?

Edw*_*uay 6 wpf xaml

当单击带有内容"Reports"的按钮时,此按钮单击方法将启动一个名为"(assemblyname).Reports"的窗口:

private void Button_Click(object sender, RoutedEventArgs e)
{
    Button button = (Button)e.OriginalSource;
    Type type = this.GetType();
    Assembly assembly = type.Assembly;
    Window window = (Window)assembly.CreateInstance(String.Format("{0}.{1}", type.Namespace, button.Content));
    window.ShowDialog();
}
Run Code Online (Sandbox Code Playgroud)

但我希望按钮的Content属性值能够更改,例如它可能会更改为"Stock Reports"但我仍然希望单击按钮以启动"(assemblyname).Reports".

有没有办法向按钮标签添加属性,例如"TheWindowFileName"?

<Button x:Name="btnReports" Content="Stock Reports" TheWindowFileName="Reports"/>
Run Code Online (Sandbox Code Playgroud)

如果没有,我还能如何向我的按钮元素添加其他信息,我可以在后面的代码中阅读和处理?

Mat*_*ton 10

当然,您可以使用附加属性向XAML元素添加额外属性,但是根据您的需要,您可以使用现有的Tag属性:

<Button x:Name="btnReports" Content="Stock Reports" Tag="Reports"/>
Run Code Online (Sandbox Code Playgroud)