Browse Source

Added DropDown style.

There are a few things still missing before it can work.
Steven Kirk 10 years ago
parent
commit
2b8b5103f3

+ 55 - 0
samples/XamlTestApplicationPcl/DropDown.paml

@@ -0,0 +1,55 @@
+<Styles xmlns="https://github.com/perspex">
+  <Style Selector="DropDown">
+    <Setter Property="BorderBrush" Value="Black"/>
+    <Setter Property="BorderThickness" Value="1"/>
+    <Setter Property="HorizontalContentAlignment" Value="Center"/>
+    <Setter Property="VerticalContentAlignment" Value="Center"/>
+    <Setter Property="Template">
+      <ControlTemplate>
+        <Border Background="{TemplateBinding Background}"
+                BorderBrush="{TemplateBinding BorderBrush}"
+                BorderThickness="{TemplateBinding BorderThickness}">
+          <Grid ColumnDefinitions="*,Auto">
+            <ContentPresenter Content="{TemplateBinding Content}"
+                              Margin="{TemplateBinding Padding}"
+                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
+            <ToggleButton Name="toggle"
+                          BorderThickness="0"
+                          Background="Transparent"
+                          ClickMode="Press"
+                          Focusable="False">
+              <Path Fill="Black"
+                    Width="8"
+                    Height="4"
+                    Stretch="Uniform"
+                    HorizontalAlignment="Center"
+                    VerticalAlignment="Center"
+                    Data="F1 M 301.14,-189.041L 311.57,-189.041L 306.355,-182.942L 301.14,-189.041 Z"
+                    Grid.Column="1"/>
+            </ToggleButton>
+            <Popup Name="PART_Popup"
+                   IsOpen="{TemplateBinding Path=IsDropDownOpen, Mode=TwoWay}"
+                   MinWidth="{TemplateBinding Path=Bounds.Width}"
+                   PlacementTarget="{TemplateBinding}"
+                   StaysOpen="False">
+              <Border BorderBrush="Black"
+                      BorderThickness="1"
+                      Padding="4">
+                <ItemsPresenter Items="{TemplateBinding Items}" 
+                                MemberSelector="{TemplateBinding MemberSelector}"/>
+              </Border>
+            </Popup>
+          </Grid>
+        </Border>
+      </ControlTemplate>
+    </Setter>
+
+  </Style>
+  <Style Selector="CheckBox /template/ Path#checkMark">
+    <Setter Property="IsVisible" Value="False"/>
+  </Style>
+  <Style Selector="CheckBox:checked /template/ Path#checkMark">
+    <Setter Property="IsVisible" Value="True"/>
+  </Style>
+</Styles>

+ 1 - 0
samples/XamlTestApplicationPcl/XamlTestApp.paml

@@ -6,6 +6,7 @@
     <StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.Button.paml"/>
     <StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.Carousel.paml"/>
     <StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.CheckBox.paml"/>
+    <StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.DropDown.paml"/>
     <StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.ItemsControl.paml"/>
     <StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.ListBox.paml"/>
     <StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.ListBoxItem.paml"/>

+ 3 - 0
samples/XamlTestApplicationPcl/XamlTestApplicationPcl.csproj

@@ -169,6 +169,9 @@
     <EmbeddedResource Include="FocusAdorner.paml">
       <SubType>Designer</SubType>
     </EmbeddedResource>
+    <EmbeddedResource Include="DropDown.paml">
+      <SubType>Designer</SubType>
+    </EmbeddedResource>
     <None Include="packages.config" />
     <EmbeddedResource Include="Button.paml">
       <SubType>Designer</SubType>

+ 4 - 0
src/Markup/Perspex.Markup/Perspex.Markup.csproj

@@ -91,6 +91,10 @@
       <Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project>
       <Name>Perspex.Base</Name>
     </ProjectReference>
+    <ProjectReference Include="..\..\Perspex.SceneGraph\Perspex.SceneGraph.csproj">
+      <Project>{eb582467-6abb-43a1-b052-e981ba910e3a}</Project>
+      <Name>Perspex.SceneGraph</Name>
+    </ProjectReference>
   </ItemGroup>
   <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

+ 2 - 0
src/Perspex.Controls/Primitives/Popup.cs

@@ -3,6 +3,7 @@
 
 using System;
 using Perspex.Interactivity;
+using Perspex.Metadata;
 using Perspex.Rendering;
 using Perspex.VisualTree;
 
@@ -80,6 +81,7 @@ namespace Perspex.Controls.Primitives
         /// <summary>
         /// Gets or sets the control to display in the popup.
         /// </summary>
+        [Content]
         public Control Child
         {
             get { return GetValue(ChildProperty); }

+ 1 - 1
src/Perspex.Themes.Default/DropDownStyle.cs

@@ -120,7 +120,7 @@ namespace Perspex.Themes.Default
                         },
                         new Popup
                         {
-                            Name = "popup",
+                            Name = "PART_Popup",
                             Child = new Border
                             {
                                 BorderBrush = Brushes.Black,