Say I have the WPF Window defined in XAML:
<Window x:Class="OINA.Papyrus.ReportGeneratorPoCNetv48.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:OINA.Papyrus.ReportGeneratorPoCNetv48"
xmlns:system="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
Title="MainWindow" Height="200" Width="800">
<StackPanel Margin="20" Loaded="OnLoaded">
<StackPanel.Resources>
<system:String x:Key="Greeting">Hello, World!</system:String>
<system:String x:Key="Farewell">Goodbye, World!</system:String>
</StackPanel.Resources>
<TextBlock x:Name="myTextBlock" Text="{StaticResource Greeting}" />
</StackPanel>
</Window>
The TextBlock
element has a Text
property with the value of "Hello, World!", so within the code-behind we can simply do myTextBlock.Text
. But instead of getting the value of the Text
property, is there a way to determine the key of the resource that was used to provide the value of the Text
property, which in the example of above would be "Greeting"?