도전2022

wp7 리소스 변경하기 본문

작업/윈도우폰7

wp7 리소스 변경하기

hotdigi 2011. 7. 5. 20:56


리소스를 이용해서 사각형 스타일 결정하기.

1. 리소스를 추가한다.
2. 사각형을 그리고, 스타일 속성에서 리소스의 값을 선택한다.
    <완성>
3. Implicit Syle은 key가 없는 경우에 디폴트로 사용되는 속성으로 사용된다.

[xaml]
    shell:SystemTray.IsVisible="True">
   
    <phone:PhoneApplicationPage.Resources>
        <Style x:Key="recBlue" TargetType="Rectangle">
            <Setter Property="Fill" Value="Blue">
            </Setter>
        </Style>

        <Style TargetType="Rectangle">
            <Setter Property="Fill" Value="Blue">
            </Setter>
        </Style>
    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->

[사용]
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Button Content="Button" Height="72" HorizontalAlignment="Left" Margin="144,145,0,0" Name="button1" VerticalAlignment="Top" Width="160" Click="button1_Click" />
            <Rectangle Height="100" HorizontalAlignment="Left" Margin="131,296,0,0" Name="rectangle1" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top" Width="200" Style="{StaticResource recBlue}" />
            <Rectangle Height="91" HorizontalAlignment="Left" Margin="51,81,0,0" Name="rectangle2" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top" Width="154" />
        </Grid>

'작업 > 윈도우폰7' 카테고리의 다른 글

Execution Model for Windows Phone  (0) 2011.07.06
카메라 관련 내용.  (0) 2011.07.06
saverington에 IsoStorePath API가 제거되었다.  (0) 2011.07.06
teched 2011 동영상 모음  (0) 2011.07.05
wp7 관련 링크  (0) 2011.07.05