WPF Binding To Application Properties -
i need bind static properties in app.xaml.cs class , have far done using:
property="{binding source={x.static application.current}, path=somepath}"
this works ok when application being run directly, when application started application, these bindings don't work believe application.current points @ parent application rather application xaml sits under.
how bind immediate app.xaml.cs file properties rather parent application?
hope makes sense!
so 1 solution i've found far put class between app.xaml.cs , xaml i'm trying bind:
app.xaml.cs:
public partial class app : application { public static string sometext; protected override void onstartup(startupeventargs e) { base.onstartup(e); sometext = "here text"; } }
myproperties.cs:
public class myproperties { public static string sometext { { return app.sometext; } } }
mainwindow.xaml:
<window.resources> <local:myproperties x:key="properties"/> </window.resources> <grid> <textblock text="{binding source={staticresource properties}, path=sometext}"/> </grid>
any other suggestions still more welcome :)
Comments
Post a Comment