2013-03-12 13 views
11

मैंने ग्रिड ऐप (एक्सएएमएल) टेम्पलेट (सी # विंडोज स्टोर) से एक नई परियोजना बनाई है। अभी तक मैंने टेम्पलेट में कुछ भी नहीं बदला है, लेकिन मैं ग्रिड में एक विशिष्ट पंक्ति से पृष्ठभूमि रंग बदलना चाहता हूं।सी # पृष्ठभूमि रंग विशिष्ट पंक्ति बदलें

<!-- 
    This grid acts as a root panel for the page that defines two rows: 
    * Row 0 contains the back button and page title 
    * Row 1 contains the rest of the page layout 
--> 
<Grid Style="{StaticResource LayoutRootStyle}"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="140"/> 
     <RowDefinition Height="*"/> 
    </Grid.RowDefinitions> 

मैं पृष्ठभूमि 0 को पंक्ति 0 से बदलना चाहता हूं (जिसमें पृष्ठ शीर्षक शामिल है)। कोई विचार ?? अग्रिम में धन्यवाद!

यह पंक्ति का consits:

<!-- Back button and page title --> 
    <Grid> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="Auto"/> 
      <ColumnDefinition Width="*"/> 
     </Grid.ColumnDefinitions> 
     <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/> 
     <TextBlock x:Name="pageTitle" Text="{StaticResource AppName}" Grid.Column="1" IsHitTestVisible="false" Style="{StaticResource PageHeaderTextStyle}"/> 
    </Grid> 

उत्तर

17

आप Grid.Row पर ही पृष्ठभूमि रंग निर्धारित नहीं कर सकते, बजाय पृष्ठभूमि संपत्ति जो कुछ भी पर इस पंक्ति पर निर्धारित किया है।

उदाहरण के लिए

<Grid Style="{StaticResource LayoutRootStyle}"> 
    <Grid.RowDefinitions> 
    <RowDefinition Height="140"/> 
    <RowDefinition Height="*"/> 
    </Grid.RowDefinitions> 
    <Grid Background="Red" Grid.Row="0"> 
    <TextBlock>Test</TextBlock> 
    </Grid> 
</Grid> 

संपादित करें: सिल्वरलाइट के लिए अपडेट किया गया; टेक्स्टब्लॉक में पृष्ठभूमि नहीं है इसलिए आपको नियंत्रण को अन्य सीमा या ग्रिड कंटेनर में रखना होगा जिसमें पृष्ठभूमि है। कोड को प्रतिबिंबित करने के लिए अद्यतन किया गया।

+0

दुर्भाग्य से एक TextBlock आइटम एक पृष्ठभूमि संपत्ति के शामिल नहीं है शामिल डालने। मैंने अपनी पोस्ट को यह दिखाने के लिए संपादित किया है कि कौन सी चीजें उस पंक्ति में हैं। – user1951083

+0

आह, मेरी माफ़ी, मुझे आपकी पोस्ट पर रजत प्रकाश टैग नहीं मिला, डब्ल्यूपीएफ टेक्स्टब्लॉक में पृष्ठभूमि है। – Dutts

+0

लेकिन मैं सिर्फ बटन की पृष्ठभूमि को बदलना नहीं चाहता, यह पूरी पंक्ति होनी चाहिए। – user1951083

2

कैसे के बारे में सीमा जहां आप इसे

<Grid Style="{StaticResource LayoutRootStyle}"> 
    <Grid.RowDefinitions> 
    <RowDefinition Height="140"/> 
    <RowDefinition Height="*"/> 
    </Grid.RowDefinitions> 
    <Border Background="Red" Grid.ColumnSpan="1"></Border> 
    <TextBlock>Test</TextBlock> 
    <Border Background="blue" Grid.Row="1" Grid.ColumnSpan="1"></Border> 
    <TextBlock Grid.Row="1">Test2</TextBlock> 
</Grid> 

टिप्पणी की जरूरत है आप especify सकते हैं कि कॉलम के मामले में अवधि अधिक स्तंभों

संबंधित मुद्दे