spr*_*t12 5 silverlight wpf resources colors
我在我的xaml中定义了一个资源:
<core:WidgetBase xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" x:Class="....Silverlight.LiquidityConstraintsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:core="clr-namespace:...Silverlight;assembly=....Silverlight"
xmlns:local="clr-namespace:....Silverlight"
mc:Ignorable="d">
<core:WidgetBase.Resources>
<SolidColorBrush x:Key="..." />
</core:WidgetBase.Resources>
...
Run Code Online (Sandbox Code Playgroud)
我试图从代码中设置它:
void _administrationClient_GetByFilterModuleSettingCompleted(object sender, GetByFilterModuleSettingCompletedEventArgs e)
{
this.Resources["..."] = new SolidColorBrush(Colors.Red);
}
Run Code Online (Sandbox Code Playgroud)
但我得到错误:
该方法或操作未实现.
堆栈跟踪 :
at System.Windows.ResourceDictionary.set_Item(Object key, Object value)
at ....Silverlight.LiquidityConstraintsView._administrationClient_GetByFilterModuleSettingCompleted(Object sender, GetByFilterModuleSettingCompletedEventArgs e)
at ....Service.AdministrationServiceClient.OnGetByFilterModuleSettingCompleted(Object state)
Run Code Online (Sandbox Code Playgroud)
当我向服务器发送请求以获取颜色时会发生这种情况,然后当它返回时我尝试将该颜色设置为资源,即使我尝试在此时将其设置为红色也会失败.
如果它有帮助,我设置它的方法是从WCF调用到服务器的异步回调方法.
如果你看一下ResourceDictionary
Reflector(对于Silverlight)的setter ,你会看到它抛出一个NotImplementedException
,所以这在Silverlight中不起作用.
您可以尝试删除资源并重新添加它,但这是在黑暗中拍摄的.
归档时间: |
|
查看次数: |
1462 次 |
最近记录: |