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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -