2015-12-11 4 views
11

जब combobox में और अधिक आइटम होते हैं, तो combobox listpicker flyout दिखाएगा। यदि मैं पहले का चयन करता हूं और नीचे स्क्रॉल करता हूं, तो एक से अधिक आइटम चयनित के रूप में दिखाए जाएंगे। लेकिन कॉम्बोबॉक्स का चयनित इटिम वह होगा जिसे मैंने चुना था। मैंने ListPickerFlyout की शैली को संशोधित किया और ListView के वर्चुअलाइजेशन को बंद कर दिया। यदि मैं ऐसा करता हूं तो ListView चयनित इटैम को बनाए रखेगा। क्या यह कॉम्बोबॉक्स का बग है? वहाँ इस समस्या के लिए किसी भी समाधान हैविंडोज फोन 8.1 कॉम्बोबॉक्स कई आइटम दिखाता है जब आइटम की संख्या अधिक होती है

यहाँ शैली जो मैं संशोधित

<DataTemplate x:Key="ListPickerFlyoutPresenterContentTemplate" > 
       <ListView VirtualizingStackPanel.VirtualizationMode="Recycling" SelectionMode="Single" > 
        <!--<ListView.ItemsPanel> 
         <ItemsPanelTemplate> 
          <VirtualizingStackPanel/> 
         </ItemsPanelTemplate> 
        </ListView.ItemsPanel>--> 
        <ListView.ItemContainerStyle> 

          <Setter Property="Template"> 
           <Setter.Value> 
            <ControlTemplate TargetType="ListViewItem"> 
             <Border x:Name="OuterContainer" RenderTransformOrigin="0.5,0.5"> 
              <VisualStateManager.VisualStateGroups> 
               <VisualStateGroup x:Name="CommonStates"> 
                <VisualState x:Name="Normal" /> 
                <VisualState x:Name="Pressed"/> 

                <VisualState x:Name="Disabled"/> 
                                         <VisualStateGroup.Transitions> 
                 <VisualTransition From="Pressed" To="Normal" /> 


                </VisualStateGroup.Transitions> 
               </VisualStateGroup> 
               <VisualStateGroup x:Name="SelectionStates"> 
                <VisualState x:Name="Unselected" /> 
                <VisualState x:Name="Selected"> 
                 <Storyboard> 
                  <DoubleAnimation Storyboard.TargetName="CheckGlyph" Storyboard.TargetProperty="Opacity" Duration="0" To="1" /> 
                  <DoubleAnimation Storyboard.TargetName="SelectedCheckMark" Storyboard.TargetProperty="Opacity" Duration="0" To="1" /> 
                  <ObjectAnimationUsingKeyFrames Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="Foreground" Duration="0"> 
                   <DiscreteObjectKeyFrame KeyTime="0" Value="Green" /> 
                  </ObjectAnimationUsingKeyFrames> 
                  <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentBorder" Storyboard.TargetProperty="Background"> 
                   <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ListPickerFlyoutPresenterSelectedItemBackgroundThemeBrush}" /> 
                  </ObjectAnimationUsingKeyFrames> 
                 </Storyboard> 
                </VisualState> 
                <VisualState x:Name="SelectedUnfocused"> 
                 <Storyboard> 
                  <DoubleAnimation Storyboard.TargetName="CheckGlyph" Storyboard.TargetProperty="Opacity" Duration="0" To="1" /> 
                  <DoubleAnimation Storyboard.TargetName="SelectedCheckMark" Storyboard.TargetProperty="Opacity" Duration="0" To="1" /> 
                  <ObjectAnimationUsingKeyFrames Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="Foreground" Duration="0"> 
                   <DiscreteObjectKeyFrame KeyTime="0" Value="Green" /> 
                  </ObjectAnimationUsingKeyFrames> 
                  <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentBorder" Storyboard.TargetProperty="Background"> 
                   <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ListPickerFlyoutPresenterSelectedItemBackgroundThemeBrush}" /> 
                  </ObjectAnimationUsingKeyFrames> 
                 </Storyboard> 
                </VisualState> 
               </VisualStateGroup> 
               <VisualStateGroup x:Name="DataVirtualizationStates"> 
                <VisualState x:Name="DataAvailable" /> 
                <VisualState x:Name="DataPlaceholder"> 

                </VisualState> 
               </VisualStateGroup> 
               <VisualStateGroup x:Name="MultiSelectStates"> 
                <VisualState x:Name="NoMultiSelect" /> 
                <VisualState x:Name="ListMultiSelect"> 

                </VisualState> 
                <VisualState x:Name="GridMultiSelect" /> 
                <VisualStateGroup.Transitions> 
                 <VisualTransition From="ListMultiSelect" To="NoMultiSelect" GeneratedDuration="0:0:0.15" /> 
                 <VisualTransition From="NoMultiSelect" To="ListMultiSelect" GeneratedDuration="0:0:0.15" /> 
                </VisualStateGroup.Transitions> 
               </VisualStateGroup> 
               <!--<VisualStateGroup x:Name="HighlightStates"> 
                <VisualState x:Name="NoHighlight" /> 
                <VisualState x:Name="Highlighted"> 
                 <Storyboard> 
                  <ObjectAnimationUsingKeyFrames Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="Foreground" Duration="0"> 
                   <DiscreteObjectKeyFrame KeyTime="0" Value="Red" /> 
                  </ObjectAnimationUsingKeyFrames> 
                  <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentBorder" Storyboard.TargetProperty="Background"> 
                   <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ListPickerFlyoutPresenterSelectedItemBackgroundThemeBrush}" /> 
                  </ObjectAnimationUsingKeyFrames> 
                 </Storyboard> 
                </VisualState> 
               </VisualStateGroup>--> 
              </VisualStateManager.VisualStateGroups> 

                  <Grid> 
                   <ContentPresenter x:Name="contentPresenter" 
             ContentTransitions="{TemplateBinding ContentTransitions}" 
             ContentTemplate="{TemplateBinding ContentTemplate}" 
             Content="{TemplateBinding Content}" 
             HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
             VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
             Margin="{TemplateBinding Padding}" 
             Style="{ThemeResource FlyoutPickerListViewItemContentPresenterStyle}" /> 
                   <!--The 'Xg' text simulates the amount of space one line of text will occupy. 
              In the DataPlaceholder state, the Content is not loaded yet so we 
              approximate the size of the item using placeholder text.--> 
                   <TextBlock x:Name="PlaceholderTextBlock" 
           Opacity="0" 
           Text="Xg" 
           Foreground="{x:Null}" 
           Margin="{TemplateBinding Padding}" 
           IsHitTestVisible="False" 
           AutomationProperties.AccessibilityView="Raw"/> 
                   <Rectangle x:Name="PlaceholderRect" 
           Visibility="Collapsed" 
           Fill="{ThemeResource FlyoutBackgroundThemeBrush}" 
           IsHitTestVisible="False" /> 
                  </Grid> 
                 </Border> 
                </Border> 
               </Border> 
               <Border x:Name="SelectedBorder" 
         IsHitTestVisible="False" 
         Opacity="0" 
         BorderBrush="{ThemeResource ListViewItemSelectedBackgroundThemeBrush}" 
         BorderThickness="{ThemeResource GridViewItemMultiselectBorderThickness}"> 
                <Grid x:Name="SelectedCheckMark" 
         Opacity="0" 
         Height="34" 
         Width="34" 
         HorizontalAlignment="Right" 
         VerticalAlignment="Top"> 
                 <Path x:Name="SelectedEarmark" Data="M0,0 L40,0 L40,40 z" 
         Fill="{ThemeResource ListViewItemSelectedBackgroundThemeBrush}" 
         Stretch="Fill" /> 
                 <Path x:Name="SelectedGlyph" 
         Data="M0,123 L39,93 L124,164 L256,18 L295,49 L124,240 z" 
         Fill="{ThemeResource ListViewItemCheckThemeBrush}" 
         Height="14.5" 
         Stretch="Fill" 
         Width="17" 
         HorizontalAlignment="Right" 
         Margin="0,1,1,0" 
         VerticalAlignment="Top" 
         FlowDirection="LeftToRight" /> 
                </Grid> 
               </Border> 
              </Grid> 
             </Border> 
            </ControlTemplate> 
           </Setter.Value> 
          </Setter> 
         </Style> 

        </ListView.ItemContainerStyle> 
        <ListView.Footer> 
         <Border Height="{ThemeResource ListPickerFlyoutFooterThemeHeight}" Width="1" /> 
        </ListView.Footer>      
       </ListView> 
      </DataTemplate> 

जब मैं कुछ आइटम यह अभ्यस्त चयनित दृश्य राज्य के लिए जाने का चयन करें, यह वास्तव में दृश्य राज्य और जब हाइलाइट किया गया करने के लिए हो जाता है है मैं बंद वर्चुअलाइजेशन पिछले हाइलाइट किए गए राज्य को

+0

के रूप में चुना जब आइटम की संख्या more' और उसके बाद कर रहे हैं मैं एक छोटे से क्या आप 'का वर्णन कर रहे हैं एक से अधिक आइटम से पता चलता द्वारा संदेह में हूँ 'जब मैं कुछ आइटम चुनता हूं तो यह चयनित दृश्य स्थिति पर नहीं जाता है, यह वास्तव में हाइलाइट किए गए दृश्य स्थिति पर जाता है और जब मैं वर्चुअलाइजेशन को बंद करता हूं तो पिछले हाइलाइट किए गए राज्य को' –

+0

'बनाए रखा नहीं जाएगा यदि मैं किसी भी शैली को संपादित नहीं करता हूं, तो combobox का वास्तविक व्यवहार है- एक का चयन करें सूचीपिकर से आइटम और फिर सूचीपिकर पर जाएं और नीचे स्क्रॉल करें, एक से अधिक आइटम चयनित के रूप में दिखाए जाते हैं (यह केवल तभी होगा जब कम्बोबॉक्स में कई आइटम हों) – Archana

+0

जब मैं कुछ आइटम चुनता हूं तो यह चयनित दृश्य स्थिति पर नहीं जाता है, यह वास्तव में हाइलाइट किया जाता है विज़ ual state और जब मैं वर्चुअलाइजेशन को पिछला हाइलाइट किया गया राज्य को बरकरार रखा नहीं जाता --- --- जब मैंने ListPickerFlyoutPresenterContentTemplate को संपादित किया, मैंने देखा कि जब सूचीपिकर में कोई आइटम क्लिक किया जाता है (चयनित) यह हमेशा हाइलाइट किए गए दृश्य स्थिति पर जाता है दृश्य दृश्य – Archana

उत्तर

1

समस्या को सूचीदृश्य (यह नियंत्रण में एक बग) के वर्चुअलाइजेशन के साथ है।

इसका समाधान सूचीदृश्य के आइटम्सस्टैकपैनल की CacheLength संपत्ति सेट करना है।

कोड है:

<DataTemplate x:Key="ListPickerFlyoutPresenterContentTemplate"> 
    <ListView ItemContainerStyle="{StaticResource ListPickerFlyoutPresenterItemStyle}"> 
     <ListView.ItemsPanel> 
      <ItemsPanelTemplate> 
       <ItemsStackPanel CacheLength="10" /> 
      </ItemsPanelTemplate> 
     </ListView.ItemsPanel> 

     <ListView.Footer> 
      <Border Height="{ThemeResource ListPickerFlyoutFooterThemeHeight}" 
        Width="1" /> 
     </ListView.Footer> 
    </ListView> 
</DataTemplate> 

समाधान कुछ समय (कुछ सेकंड) के बाद selction आकर्षण को हटा के बाद ही आइटम महसूस किया है।

आशा है कि समाधान बाकी ठीक है आप सूचीदृश्य की PrepareContainerForItemOverride ओवरराइड करना होगा

+0

अपना कोड जांचें। जैसा कि आपने कहा है कि हाइलाइट कुछ सेकंड के लिए होगा – Archana

+0

क्या आप इस [लिंक] में मेरी सहायता कर सकते हैं (http://stackoverflow.com/questions/35450295/windows-phone-8-1-music-library-get-current-media -कतार) – Archana

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