C# と VB.NET の質問掲示板

わんくま同盟

ASP.NET、C++/CLI、Java 何でもどうぞ

C# と VB.NET の入門サイト


(過去ログ 130 を表示中)
■77234 / )  Re[2]: XAMLからのアプリケーション設定参照方法
□投稿者/ まさ (7回)-(2015/09/29(Tue) 18:03:05)
No77232 (WebSurfer さん) に返信

>>http://yohshiy.blog.fc2.com/blog-entry-253.html
> どのコードを、どのように試して、どこで例外がスローされたのですか?

(1) リソース登録するためApp.xamlを編集
(2) アプリケーション設定の「FilePath」をtextBoxにバインドするため、MainWindow.xamlを編集
(3) 実行してWindowを開くと「System.Windows.StaticResourceExtension」発生
という流れです。

App.xaml
-----------------------------
<Application x:Class="MakeOrderFile.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:prop="clr-namespace:WpfApplication1.Properties"
>
<Application.Resources>
<prop:Settings x:Key="sett" />
</Application.Resources>
</Application>
-----------------------------

MainWindow.xaml
-----------------------------
<Window x:Class="MakeOrderFile.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:MakeOrderFile"
mc:Ignorable="d"
Title="" Height="200" Width="200">
<Grid Height="199" VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBox x:Name="textBox" Height="17" TextWrapping="Wrap" Text="{Binding FilePath, Mode=OneWay, Source={StaticResource sett}}" VerticalAlignment="Top" Margin="40,0,30,0"/>
</Grid>
</Window>

-----------------------------


> それから、ご自分の開発環境(OS, .NET, Visual Studio のバージョンなど)を書
> いていただけませんか?
(Windows7、.NET 4.5.2、Visual Studio2015)


> ??? さんとはどなたでしょうか?
失礼しました。
返信 編集キー/


管理者用

- Child Tree -