0
 <Window x:Class="logf.Circles"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Circles" Height="426" Width="581" Name="Cir">
    <Grid Background="Beige">
        <Grid.Resources>
            <Style x:Key="myfirst">
              <Setter Property="Height" Value="150" />
                <Setter Property="HorizontalAlignment" Value="Left"/>
                <Setter Property="Margin" Value="1"/>
                <Setter Property="Width" Value="150" />
            </Style>


        </Grid.Resources>
        <Ellipse Style="{StaticResource myfirst}" Fill="red"  Name="ellipse1" Stroke="Black" VerticalAlignment="Top" />
        <Ellipse Style="{StaticResource myfirst}" Fill="Orange"  Name="ellipse2" Stroke="Black" VerticalAlignment="Top" Margin="1" HorizontalAlignment="Center" />
        <Ellipse Style="{StaticResource myfirst}" Fill="green"  Name="ellipse3" Stroke="Black" VerticalAlignment="Top" HorizontalAlignment="Right"/>
        <Button Content="Replace" Name="button1" Tag="c_replace" ToolTip="To replace color" Margin="100" Click="button1_Click" HorizontalAlignment="Stretch" VerticalAlignment="Center" Padding="20" HorizontalContentAlignment="Center" />
    </Grid>


</Window>

上記は、circles.xaml の私の xaml コードです。

私はWPFが初めてで、本当にばかげているかもしれないことを尋ねたかったのです。xaml ファイルを作成し、それを MainWindow.xaml.cs ファイルで使用したいと考えました。しかし、私はそれを言ってエラーが発生します

「型または名前空間名 'filename' が見つかりませんでした (using ディレクティブまたはアセンブリ参照がありませんか?)」.

.xaml and .xaml.cs同じクラス内のファイル間の相互作用を行う方法。ありがとう。

4

1 に答える 1