2013-02-14 24 views
16

से अधिक सेट है WPF और XAML के लिए बहुत नया। मैं अपने सिर को चारों ओर नहीं प्राप्त कर सकता हूं कि मैं एक डब्ल्यूपीएफ नियंत्रण क्यों नहीं डाल सकता जहां मैं निम्नलिखित कोड में चाहूंगा। मेरा मुद्दा यह है कि <canvas></canvas> टैग हैं। मैंने इस जगह में जो कुछ भी रखा है, वह मुझे 'संपत्ति' सामग्री 'एक बार से अधिक सेट किया गया है'एक्सएएमएल - संपत्ति 'सामग्री' एक बार

यदि कोई साधारण शर्तों में समझा सकता है जहां सामग्री संपत्ति सेट की गई है तो यह सबसे उपयोगी होगी।

मैं कोई लाभ नहीं हुआ तो निम्नलिखित लेख जाँच कर ली है: the property 'Content' is set more than once the property content is set more than once Property content is set more than once The property 'Content' is set more than once Button WPF ControlTemplate causeing error "The property 'content' is set more than once"

<Window x:Class="PDFIndexer.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="MainWindow" Height="350" Width="525"> 
<Grid x:Name="ParentGrid"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="Auto" /> 
     <RowDefinition Height="1*" /> 
     <RowDefinition Height="25" /> 
    </Grid.RowDefinitions> 
    <Menu Grid.Row="0" > 
     <MenuItem Header="File" > 
      <MenuItem Header="Open Project" Click="MenuItem_Click_1"></MenuItem> 
      <MenuItem Header="Save Project"></MenuItem> 
      <MenuItem Header="Close Project"></MenuItem> 
      <Separator></Separator> 
      <MenuItem Header="Exit"></MenuItem> 
     </MenuItem> 
     <MenuItem Header="Edit"></MenuItem> 
    </Menu> 
    <TabControl Grid.Row="1"> 
     <TabItem Header="Document Flow" > 
      This is where the outline of the entire document will be placed. 
      <Canvas></Canvas> 
     </TabItem> 
     <TabItem Header="Preview"> 
      This is where the preview will be drawn to screen. 
     </TabItem> 
     <TabItem Header="Resources"> 
      This is where the resources { graphic files, fonts, data files } 
     </TabItem> 
     <TabItem Header="Code Library"> 
      This is where the user can save re-usable bits of code. Useful when adding intel barcodes or Address blocks etc... 
     </TabItem> 
    </TabControl> 


    <StatusBar Grid.Row="2"> 
     Items 
    </StatusBar> 
</Grid> 

+2

टैबइटेम केवल एक हाथी की गणना कर सकता है। क्या आप वास्तव में कैनवास टैग के तहत या उसी स्तर पर कैनवास के साथ अपनी सामग्री जोड़ने की कोशिश करते हैं (यह काम नहीं करेगा)? –

उत्तर

26

करने के लिए अपने पाठ वर्णन जोड़ कर अपने TabItem आप तो सामग्री जोड़ा जब आप कैनवास जोड़ा आप सामग्री का एक अतिरिक्त आइटम जो TabItem लिए अनुमति नहीं है जोड़ा । आपको ऐसे नियंत्रण का उपयोग करने की आवश्यकता है जो collection of Children जैसे कैनवास, ग्रिड, स्टैकपैनेल आदि को पकड़ सके। इस तरह कुछ करने का प्रयास करें।

<TabControl Grid.Row="1"> 
    <TabItem Header="Document Flow"> 
     <Canvas> 
      <TextBlock> 
       This is where the outline of the entire document will be placed. 
      </TextBlock> 
     </Canvas> 
    </TabItem> 
    <TabItem Header="Preview"> 
     This is where the preview will be drawn to screen. 
    </TabItem> 
    <TabItem Header="Resources"> 
     This is where the resources { graphic files, fonts, data files } 
    </TabItem> 
    <TabItem Header="Code Library"> 
     This is where the user can save re-usable bits of code. Useful when adding intel barcodes or Address blocks etc... 
    </TabItem> 
</TabControl> 
+2

धन्यवाद। पूरी तरह से काम किया। आपकी व्याख्या की स्पष्टता के कारण मुझे आपको स्वीकार्य उत्तर देना पड़ा। – berniefitz

1

कोशिश एक Grid में TabItem की सामग्री लपेट और करने के लिए उपयोग करने के लिए TextBlock टेक्स्ट दिखाएं:

<TabItem Header="Document Flow" > 
    <Grid> 
     <TextBlock Text="This is where the outline of the entire document will be placed."/> 
     <Canvas></Canvas> 
    </Grid> 
</TabItem> 
1

कुछ कंटेनर केवल 1 तत्व की अनुमति देते हैं, अन्य कंटेनर> 1 तत्व की अनुमति देते हैं। जब आपको त्रुटि संदेश 'सामग्री' एक से अधिक बार सेट किया जाता है, तो इसका मतलब है कि आपने एक कंटेनर में एक से अधिक प्रकार के तत्व डालने का प्रयास किया है जो केवल 1 तत्व की अनुमति देता है।

हो सकता है कि यह (परीक्षण नहीं) की कोशिश:

<TabItem Header="Document Flow" > 
<StackPanel> 
<TextBlock>This is where the outline of the entire document will be placed. </TextBlock> 
<Canvas></Canvas> 
</StackPanel> 
</TabItem>