<Window x:Class="Test_X_Static.MainWindow"
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:local="clr-namespace:Test_X_Static"
xmlns:prop="clr-namespace:Test_X_Static.Properties"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TextBlock Text="{x:Static prop:Resources.Name}" />
</Grid>
</Window>
在設計時已經顯示了正確的值

為什么Debug一啟動就報例外

uj5u.com熱心網友回復:
“查看詳細資訊”里的內容貼出來看看呢uj5u.com熱心網友回復:
報錯詳細內容如下:
uj5u.com熱心網友回復:
提示的很明顯了,不能認為時靜態屬性。 把靜態屬性值放到ViewModel層或者Windows后臺再進行系結。uj5u.com熱心網友回復:
終于在別人的問題中找到了答案,就是Resource.resx的訪問權限需要修改為public,而不能是internal
uj5u.com熱心網友回復:
Binding prop:Resources.Nameuj5u.com熱心網友回復:
The Text property of TextBlock should need binding.轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/57216.html
