将TextBlock前台绑定到xaml中的Global.cs变量
我一直在网上搜寻,试图找到一个类似的问题,但找不到任何解决我问题的方法 我有一个保存全局变量的静态类,其中一些是颜色变量,我希望能够绑定到我的xaml控件中,这样我只需更改一个变量即可更改批次(全局变量的原因) 类名称空间是将TextBlock前台绑定到xaml中的Global.cs变量,xaml,binding,silverlight-5.0,Xaml,Binding,Silverlight 5.0,我一直在网上搜寻,试图找到一个类似的问题,但找不到任何解决我问题的方法 我有一个保存全局变量的静态类,其中一些是颜色变量,我希望能够绑定到我的xaml控件中,这样我只需更改一个变量即可更改批次(全局变量的原因) 类名称空间是MyApp.Assets.Resources类名是Global(.cs)。 在我的类中,我有名为DEFAULTCOLOR、OKCOLOR和ALARMCOLOR的变量 我的xaml: <UserControl <!-- ... --> xmln
MyApp.Assets.Resources
类名是Global
(.cs)。
在我的类中,我有名为DEFAULTCOLOR
、OKCOLOR
和ALARMCOLOR
的变量
我的xaml:
<UserControl
<!-- ... -->
xmlns:custom="clr-namespace:InspectionDB.Assets.Resources"
>
<UserControl.Resources>
<custom:Global x:Name="global"/> <!-- THIS GIVES AN ERROR SEE BELOW-->
<common:HierarchicalDataTemplate x:Key="Level1" ItemsSource="{Binding Path=Children}">
<StackPanel Orientation="Horizontal">
<Image Source="{Binding Type, Converter={StaticResource localTreeImgConverter}}"/>
<TextBlock {Binding...} />
<StackPanel Orientation="Horizontal" Visibility="{Binding Type, Converter={StaticResource localStatusVisibilityConverter}}">
<TextBlock Margin="5,0, 0,0" Text="[ " Foreground="{Binding DEFAULTCOLOR, Source={StaticResource global}}" />
<TextBlock Text="{Binding Critical}" Foreground="{Binding ALARMCOLOR, Source={StaticResource global}}"/>
<TextBlock Text=" | " Foreground="{Binding DEFAULTCOLOR, Source={StaticResource global}}"/>
<TextBlock Text="{Binding OK}" Foreground="{Binding OKCOLOR, Source={StaticResource global}}"/>
<TextBlock Text=" ]" Foreground="{Binding DEFAULTCOLOR, Source={StaticResource global}}"/>
</StackPanel>
</StackPanel>
</common:HierarchicalDataTemplate>
</UserControl.Resources>
<Grid>
<!-- Where the hierarchical template is used -->
</Grid>
</UserControl>
我的代码出了什么问题,如何才能使其正常工作?我发现了我的问题所在,因此我无法找到任何类似的情况 我有
公共类Global:App
-别问我为什么,我肯定很久以前有一个合理的理由,但这意味着它有一些古怪的循环引用
问题解决了
Unable to cast object of type 'ApplicationProxy' to type 'Microsoft.Expression.DesignModel.DocumentModel.DocumentNode'.