动态将样式绑定到网格 [英] dynamically binding styles to grid

查看:116
本文介绍了动态将样式绑定到网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好
IAM练习Silverlight示例

所以在我的应用程序中有一个网格,上面有stles,所以这种样式是(Assets/Styles.xaml)
在那里

在iam背后的代码中这样写

hello
iam practice the silverlight examples

so in my application have a grid having stles so this styles is (Assets/Styles.xaml)
there

in codebehind iam wrote like this

ResourceDictionary r = new ResourceDictionary();
r.Source = new Uri("/Assets/Styles.xaml", UriKind.Relative);
Style s = (Style)r["BigGridStyle"];
PageContainer.Style = s;



在styles.xaml页面中这样写



in styles.xaml page wrote like this

<Style x:Key="BigGridStyle" TargetType="Grid">
           <Setter Property="Background">
               <Setter.Value>
                   <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                       <GradientStop Color="Blue"></GradientStop>
                       <GradientStop Color="Yellow" Offset="1"></GradientStop>
                   </LinearGradientBrush>
               </Setter.Value>
           </Setter>
       </Style>


在xaml页面绑定staticresource中像这样


in xaml page binding staticresource like this

<Grid x:Name="PageContainer" Margin="47,224,49,207" Style="{StaticResource BigGridStyle}"   />


但这对我不起作用,它给出了错误
像这样
错误:


but it''s not working for me it''s giving error
like this
Error:

[Arg_COMException]
Arguments:
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=5.0.60401.00&File=mscorlib.dll&Key=Arg_COMException





那你能告诉我我错了吗?

谢谢& Advance





So can you any one tell me where i wrong?

Thanks & Advance

推荐答案

XAML看起来不错.您是否已安装 Silverlight Developer Runtime ?
The XAML looks fine. Have you installed the Silverlight Developer Runtime?


这篇关于动态将样式绑定到网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆