Dear All,
I have a class (Session), which contain static property. Static property contain Brush type property (ForeGround). I want to bind Foreground property in a resource in wpf xaml.
(Foreground="{Binding Source={StaticResource session}, Path=Object.ForeGround}") does not work
I am unable to bind Foreground property.
Below is sample code
public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); Session.Object = new Info() { ForeGround = Brushes.White }; } private void Window_Loaded_1(object sender, RoutedEventArgs e) { //If I quick watch item. i got session object, and required foreground value is Ok. var item = this.FindResource("session"); } } //***************************************** public class Session { public static Info Object { get; set; } } //************************************** public class Info { public Brush ForeGround { get; set; } }
and here is WPF XAML
<Window.Resources><local:Session x:Key="session"/> </Window.Resources><Grid removed="Gray"><Viewbox><TextBlock Name="txt" Text="Hello Text" Foreground="{Binding Source={StaticResource session}, Path=Object.ForeGround}"/></Viewbox></Grid>