Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
55
Field chooser layout
posted

I have created a style to rotate some of the columns and display them verically within XamDataGrid. This works fine but when i apply this style to columns, the columns are displayed vertically in the field chooser as well. I tried creating a seperate style for field chooser which i have given below but the column header is still getting displayed vertically in field chooser. Can you please let me know how to solve this problem? 

----Vertical Header----

 <Style x:Key="VerticalHeader" TargetType="{x:Type controls:LabelPresenter}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:LabelPresenter">
                    <Border BorderBrush="{StaticResource WarmGrey_74}" Background="{StaticResource WarmGrey_74}">
                        <TextBlock Foreground="{StaticResource NptBlue_DarkText}" FontWeight="Bold"
                                   VerticalAlignment="Center" HorizontalAlignment="Left" TextAlignment="Center">
                        <ContentPresenter>
                            <ContentPresenter.LayoutTransform>
                                <RotateTransform Angle="-90" />
                            </ContentPresenter.LayoutTransform>
                        </ContentPresenter>
                        </TextBlock>
                    </Border>
                </ControlTemplate>
            </Setter.Value>           
        </Setter>
    </Style>

----Field chooser----

 <Style x:Key="{x:Type controls:FieldChooser}" TargetType="{x:Type controls:FieldChooser}">
        <Style.Resources>
            <!--FieldChooserEntry represents a field in the field chooser. This data template shows
         the checkbox inside the label presenter instead of the default which is show it left of
         the label presenter.-->
            <DataTemplate DataType="{x:Type controls:FieldChooserEntry}">
                <Grid>
                    <controls:LabelPresenter
          x:Name="label"
          HorizontalAlignment="Stretch"
          VerticalAlignment="Stretch"
          Field="{Binding Path=Field}"
          IsInFieldChooser="true"
          IsSelectedInFieldChooser="{Binding Path=IsSelected}"
          Padding="30,7,2,7">
                        <controls:LabelPresenter.Style>
                            <Style TargetType="{x:Type controls:LabelPresenter}">
                                <Setter Property="Background" Value="{StaticResource WarmGrey_74}" />
                                <Setter Property="Foreground" Value="{StaticResource NptBlue_DarkText}" />
                                <Setter Property="FontWeight" Value="Bold" />
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type controls:LabelPresenter}">
                                            <Grid>
                                                <Rectangle Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" SnapsToDevicePixels="True" />
                                                <Rectangle
                 x:Name="Highlight"
                 Height="1"
                 Margin="1"
                 VerticalAlignment="Top"
                 Stroke="#838383"
                  SnapsToDevicePixels="True"
                 StrokeThickness="1"/>
                                                <ContentPresenter TextElement.Foreground="{TemplateBinding Foreground}" Margin="{TemplateBinding Padding}" >
                                                </ContentPresenter>
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter Property="Cursor" Value="Hand"/>
                                                    <Setter Property="Background" Value="{StaticResource WarmGrey_74}">
                                                    </Setter>
                                                </Trigger>
                                                <Trigger Property="IsSelectedInFieldChooser" Value="True">
                                                    <Setter Property="Background" Value="{StaticResource WarmGrey_74}">                                                      
                                                    </Setter>
                                                    <Setter TargetName="Highlight" Property="Stroke" Value="{StaticResource NptBlue_LightText}"/>
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </controls:LabelPresenter.Style>
                        <!--This is for toggling the visibility of a field by double clicking on it in the field chooser.-->
                        <controls:LabelPresenter.InputBindings>
                            <MouseBinding Command="{x:Static controls:FieldChooserCommands.ToggleVisibility}" MouseAction="LeftDoubleClick"/>
                        </controls:LabelPresenter.InputBindings>
                    </controls:LabelPresenter>
                    <editors:XamCheckEditor
          x:Name="checkBox"
          HorizontalAlignment="Left"
          VerticalAlignment="Center"
          Margin="10,0,0,0"
          IsThreeState="false"
          Value="{Binding Path=IsVisible, Mode=TwoWay}"/>
                </Grid>
                <DataTemplate.Triggers>
                    <!-- This trigger changes the appearance of labels in the field chooser that are currently
           hidden in the data presenter. -->
                    <DataTrigger Binding="{Binding Path=IsVisible}" Value="False">
                        <Setter TargetName="label" Property="Background" Value="{StaticResource WarmGrey_74}">                           
                        </Setter>
                        <Setter TargetName="label" Property="Foreground" Value="{StaticResource NptBlue_DarkText}"/>
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>
        </Style.Resources>
        <Style.Triggers>
            <!-- You can show some kind of visual queue when the user drags a field from the field chooser by
       using IsDraggingItem property.-->
            <Trigger Property="IsDraggingItem" Value="true">
                <Setter Property="BorderThickness" Value="2"/>
                <Setter Property="BorderBrush" Value="Blue"/>
            </Trigger>
            <!-- You can show some kind of visual queue when the user drags a field from the data presenter
       using the IsDraggingItemFromDataPresenter property.-->
            <Trigger Property="IsDraggingItemFromDataPresenter" Value="true">
                <Setter Property="BorderThickness" Value="2"/>
                <Setter Property="BorderBrush" Value="Gray"/>
            </Trigger>
            <!-- You can show some kind of visual queue when the user drags a field from the data presenter
       and moves it over the field chooser by using the IsDragItemOver property.-->
            <Trigger Property="IsDragItemOver" Value="true">
                <Setter Property="BorderThickness" Value="2"/>
                <Setter Property="BorderBrush" Value="Green"/>
            </Trigger>
        </Style.Triggers>
    </Style>