2015-11-02 100 views
0

我想用我的.resw文件中的字符串设置ContentDialog的PrimaryButtonText,SecondaryButtonText和Title属性。不幸的是,Ι只能使用x:Uid做一个属性,因为在ContentDialog中设置x:Uid两次是不能接受的。我甚至试图做这样的事情:将.resw文件中的多个字符串资源用于ContentDialog

<ContentDialog> 
<ContentDialog.PrimaryButtonText x:Uid="DialogConfirm" /> 
    <ContentDialog.SecondaryButtonText x:Uid="DialogCancel" /> 
</ContentDialog> 

但我得到一个异常

XBF产生错误代码0x09c8

有没有办法做到这一点?

回答

3

X:的Uid仅对ContentDialog然后在资源文件中设置apropriate属性(take a look at MSDN):

<ContentDialog x:Uid="myDialog"> 
    <!--your dialog--> 
</ContentDialog> 

Resources.resw组:

myDialog.PrimaryButtonText -> text for primary button 
myDialog.SecondaryButtonText -> text for secondary button 

至于more guidelines and help, see MSDN

+0

谢谢!我唯一不喜欢的是,对于我创建的每个自定义ContentDialog,我需要添加3个字符串资源,因为标题对于每个标题都是不同的。 – Stam

+0

@Stam你可以看看[本地化资源的替代实现](http://stackoverflow.com/a/24258472/2681948) - 在某些情况下,我使用它。 – Romasz

相关问题