Bind の例


あまりまとまった情報がない・・・

その1 Settings.settings

<Window x:Class="WpfApplication2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:p="clr-namespace:WpfApplication2.Properties"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <TextBox Height="77" HorizontalAlignment="Left" Margin="138,82,0,0" Name="textBox1" VerticalAlignment="Top" Width="238"
                 Text="{Binding Path=TestString1, Source={x:Static p:Settings.Default}}"
                 FontSize="{Binding Path=FontSize, Source={x:Static p:Settings.Default}}"
                 Foreground="{Binding Path=Color3, Source={x:Static p:Settings.Default}}"
                 Background="{Binding Path=Color2, Source={x:Static p:Settings.Default}}"
                 />
    </Grid>
</Window>

————————–

その2 Resources

<Window
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:src="clr-namespace:SDKSample"
  SizeToContent="WidthAndHeight"
  Title="Simple Data Binding Sample">

  <Window.Resources>
    <src:Person x:Key="myDataSource" PersonName="Joe"/>
<TextBlock Text="{Binding Source={StaticResource myDataSource}, Path=PersonName}"/>

コメントを残す