English 中文(简体)
1. 改变 w夫静态资源的价值
原标题:Change the value of a wpf static resource

如何在运行时间改变世界森林论坛固定资源的价值?

我有以下资源:

<UserControl.Resources>
    <sys:String x:Key="LengthFormat">#.# mm</sys:String>
    <sys:String x:Key="AreaFormat">#.# mm²</sys:String>
    <sys:String x:Key="InertiaFormat">#.# mm⁴</sys:String>
</UserControl.Resources>

某些案文栏目参考

<TextBlock Grid.Row="2" Grid.Column="1" 
 Text="{Binding Path=Breadth, StringFormat={StaticResource ResourceKey=LengthFormat}}" />

then depending on the object to be bound to the control i would like to change the formats. I have set up properties in the control as follows:

public string LengthFormat
{
    set
    {
        this.Resources["LengthFormat"] = value;
    }
}
public string AreaFormat
{
    set
    {
        this.Resources["AreaFormat"] = value;
    }
}
public string InertiaFormat
{
    set
    {
        this.Resources["InertiaFormat"] = value;
    }
}

之后,先具有约束力的一则指示。

However it doesn t work, anyone suggest whynot?

卡车

问题回答

最为明显的办法是改用<代码>DynamicResource,即该代码。

实际上,它只是罚款。 但是,由于资源钥匙没有得到遵守,因此,“倡议”没有更新。

如果你想要能够改变的约束力的话,你就不使用静态资源。 相反,使用定期约束,代之以<条码> 指定财产,使财产调查股能够观察变化。

我同意Claus的看法,因为静态资源获得后,德国马克升值。 我建议尝试把静态资源转变为动态资源。

<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding Path=Breadth, StringFormat={DynamicResource ResourceKey=LengthFormat}}" />




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签