WP7 Toolkit AutoCompleteBox 在 Pivot and Panorama无法正常显示的解决方案

在官方Issue Tracker 有人提出这个BUG

http://silverlight.codeplex.com/workitem/7574

主要说了牛人 Jeff Wilcox 提供了解决方案

http://www.jeff.wilcox.name/2011/03/acb-in-pivot/

最好下载:根据代码最好理解了

[ZIP] 31 KB – AutoCompletePivot.zip

http://www.jeff.wilcox.name/wp-content/uploads/2011/03/AutoCompletePivot.zip

 

代码很多就不仔细说了;

复制Converters/VisibilityConverter.cs 到你的工程

然后 在xaml 里  OK 搞定!~

< Grid.Resources >
     < localControls:VisibilityConverter x:Key = "Vis" />
</ Grid.Resources >

 

< ControlTemplate TargetType = "toolkit:AutoCompleteBox" >
     < Grid >
         < Grid.RowDefinitions >
             < RowDefinition Height = "Auto" />
             < RowDefinition />
         </ Grid.RowDefinitions >
         < TextBox
             x:Name = "Text"
             Background = "{TemplateBinding Background}"
             BorderBrush = "{TemplateBinding BorderBrush}"
             BorderThickness = "{TemplateBinding BorderThickness}"
             FontFamily = "{TemplateBinding FontFamily}"
             FontSize = "{TemplateBinding FontSize}"
             FontStyle = "{TemplateBinding FontStyle}"
             FontWeight = "{TemplateBinding FontWeight}"
             Foreground = "{TemplateBinding Foreground}"
             InputScope = "{TemplateBinding InputScope}"
             Opacity = "{TemplateBinding Opacity}"
             Padding = "{TemplateBinding Padding}"
             Style = "{TemplateBinding TextBoxStyle}" />
         < ListBox
             Margin = "12"
             Visibility = "{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource Vis}}"
             Grid.Row = "1"
             x:Name = "Selector"
             Background = "White"
             FontFamily = "{TemplateBinding FontFamily}"
             FontSize = "{TemplateBinding FontSize}"
             FontStyle = "{TemplateBinding FontStyle}"
             FontWeight = "{TemplateBinding FontWeight}"
             Foreground = "{TemplateBinding Foreground}"
             IsTabStop = "False"
             ItemContainerStyle = "{TemplateBinding ItemContainerStyle}"
             ItemTemplate = "{TemplateBinding ItemTemplate}"
             Opacity = "{TemplateBinding Opacity}"
             BorderBrush = "{StaticResource PhoneTextBoxEditBorderBrush}"
             BorderThickness = "{TemplateBinding BorderThickness}"
             Padding = "0,8" />
     </ Grid >
</ ControlTemplate >

你可能感兴趣的:(autocomplete)