我有這樣的XAML我怎麼能訪問WPF窗口resoures
<mui:ModernWindow x:Uid="mui:ModernWindow_1" x:Class="App1.HomePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mui="http://firstfloorsoftware.com/ModernUI"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
ContentSource="/Window1.xaml"
Title="MainWindow" Height="350" Width="525" WindowState="Maximized" MenuLinkGroups="{Binding menuLinkGroups}">
<mui:ModernWindow.Resources>
<sys:String x:Key="ApplicationName">Bla Bla</sys:String>
</mui:ModernWindow.Resources>
<Grid Style="{StaticResource ContentRoot}" Name="mainGrid">
</Grid>
</mui:ModernWindow>
我需要引用當前窗口的資源,所以我用這個:
object obj = this.Resources["ApplicationName"];
但this.Resources不有任何資源!所以obj始終爲空。我怎樣才能參考這個窗口資源?
你從哪裏寫代碼? –
在簡單的按鈕。 – user3222589
請檢查是否有任何資源'this.Resources.Count' –