This is a migrated thread and some comments may be shown as answers.

Made a DistinctFilterControl template, now no items in distinct value list

3 Answers 94 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Doug Yoder
Top achievements
Rank 2
Doug Yoder asked on 20 Oct 2008, 04:53 PM
Hi all,

I am trying to change the controltemplate for the DistinctFilterControl of each column in a grid (we need to change the colors to match our corporate colors).  I used Expression Blend to grab a copy of the template, and started modifying the colors from there.  I got the colors changed, but now the actual filter mechanism doesn't work - the dropdown of distinct values has no items listed.  I didn't change the binding of the CheckBoxList (on line 116 of the template, below) at all... how do I fix this?

Thanks,
-Doug

<ControlTemplate x:Key="DistinctFilterTemplate" TargetType="{x:Type telerik:DistinctFilterControl}"
    <StackPanel> 
        <StackPanel.Resources> 
            <BooleanToVisibilityConverter x:Key="booleanConverter"/> 
        </StackPanel.Resources> 
        <telerik:GridViewFilteringDropDown x:Name="PART_Dropdown" VerticalAlignment="Stretch" Width="30" Height="30"
            <Border HorizontalAlignment="Stretch" x:Name="border" VerticalAlignment="Stretch" Width="Auto" Height="Auto" Background="#00FFFFFF"
                <Grid Width="11" Height="12"
                    <Path Fill="#FF000000" Stretch="Fill" Width="11" Height="12" SnapsToDevicePixels="True" Data="F1M3.9987,3.9963L15,3.9963 15,4.99479 3.9987,4.99478 3.9987,3.9963z M4.9987,4.99739L14,4.99739 14,5.99609 4.9987,5.99609 4.9987,4.99739z M5.99902,5.99869L13,5.9987 13,7 11.9984,7 11.9984,8.00391 10.999,8.00391 10.999,16.0002 7.99853,16.0002 7.99853,8.00391 6.99772,8.00391 6.99772,7 5.99902,7 5.99902,5.99869z"/> 
                    <Path Fill="#FF006699" Stretch="Fill" HorizontalAlignment="Center" Margin="0,1,0,0" VerticalAlignment="Top" Width="5" Height="3" SnapsToDevicePixels="True" Canvas.Left="3" Canvas.Top="1" Data="M7,5L12,5 12,6 7,6 7,5z M8,6L11,6 11,7 8,7 8,6z M9,7L9.99999,7 9.99999,8 9,8 9,7z"
                        <Path.Visibility> 
                            <TemplateBinding Property="HasFilterValues"
                                <!--NOTE: Visual Studio's XAML renderer currently doesn't parse TemplateBinding.Converter as an attached property, and fails the show the XAML.  It will compile and run correctly. --> 
                                <TemplateBinding.Converter> 
                                    <BooleanToVisibilityConverter/> 
                                </TemplateBinding.Converter> 
                            </TemplateBinding> 
                        </Path.Visibility> 
                    </Path> 
                </Grid> 
            </Border> 
        </telerik:GridViewFilteringDropDown> 
        <telerik:GridViewFilteringPopup HorizontalAlignment="Left" Margin="0,0,0,0" x:Name="PART_Popup" VerticalAlignment="Top" AllowsTransparency="True" IsOpen="{Binding Path=IsChecked, ElementName=PART_Dropdown, Mode=TwoWay}" Placement="Bottom" StaysOpen="False"
            <Border HorizontalAlignment="Left" VerticalAlignment="Top" BorderBrush="#89006699" BorderThickness="1,0,1,1" CornerRadius="0,0,5,5"
                <Border.Background> 
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"
                        <GradientStop Color="#E5D1EFF9" Offset="0.004"/> 
                        <GradientStop Color="#E5ADE0F3" Offset="1"/> 
                    </LinearGradientBrush> 
                </Border.Background> 
                <Border BorderBrush="#CC009DD9" BorderThickness="1,0,1,1" CornerRadius="0,0,5,5"
                    <StackPanel> 
                        <telerik:ClearFilterButton Margin="0,0,0,5" Content="Clear Filter" Foreground="#FF000000" FilterDescription="{Binding Path=FilterDescription, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type telerik:DistinctFilterControl}}}" Target="{Binding ElementName=listDistinctValues, Mode=OneTime}"
                            <telerik:ClearFilterButton.Style> 
                                <Style TargetType="{x:Type Button}"
                                    <Setter Property="FocusVisualStyle"
                                        <Setter.Value> 
                                            <Style> 
                                                <Setter Property="Control.Template"
                                                    <Setter.Value> 
                                                        <ControlTemplate> 
                                                            <Rectangle Stroke="#FF000000" StrokeDashArray="1 2" StrokeThickness="1" Margin="2,2,2,2" SnapsToDevicePixels="True"/> 
                                                        </ControlTemplate> 
                                                    </Setter.Value> 
                                                </Setter> 
                                            </Style> 
                                        </Setter.Value> 
                                    </Setter> 
                                    <Setter Property="Background"
                                        <Setter.Value> 
                                            <LinearGradientBrush EndPoint="0,1" StartPoint="0,0"
                                                <GradientStop Color="#FFF3F3F3" Offset="0"/> 
                                                <GradientStop Color="#FFEBEBEB" Offset="0.5"/> 
                                                <GradientStop Color="#FFDDDDDD" Offset="0.5"/> 
                                                <GradientStop Color="#FFCDCDCD" Offset="1"/> 
                                            </LinearGradientBrush> 
                                        </Setter.Value> 
                                    </Setter> 
                                    <Setter Property="BorderBrush" Value="#FF707070"/> 
                                    <Setter Property="BorderThickness" Value="1,1,1,1"/> 
                                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/> 
                                    <Setter Property="HorizontalContentAlignment" Value="Center"/> 
                                    <Setter Property="VerticalContentAlignment" Value="Center"/> 
                                    <Setter Property="Padding" Value="1,1,1,1"/> 
                                    <Setter Property="Template"
                                        <Setter.Value> 
                                            <ControlTemplate TargetType="{x:Type Button}"
                                                <Border x:Name="border1" Background="#FFB3C1DE" BorderBrush="#E59AACD3" BorderThickness="0,1,0,1"
                                                    <Border Margin="0,0,0,0" x:Name="border" IsEnabled="True" BorderBrush="#FFFFFFFF" BorderThickness="0,1,0,1"
                                                        <Border.Background> 
                                                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"
                                                                <GradientStop Color="#7FFFFFFF" Offset="0"/> 
                                                                <GradientStop Color="#33FFFFFF" Offset="1"/> 
                                                                <GradientStop Color="#00FFFFFF" Offset="0.531"/> 
                                                                <GradientStop Color="#33FFFFFF" Offset="0.513"/> 
                                                            </LinearGradientBrush> 
                                                        </Border.Background> 
                                                        <ContentPresenter HorizontalAlignment="Center" Margin="0,2,0,2" x:Name="contentPresenter" VerticalAlignment="Center" Width="Auto" Height="Auto" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentTemplate="{TemplateBinding ContentTemplate}" RecognizesAccessKey="True"/> 
                                                    </Border> 
                                                </Border> 
                                                <ControlTemplate.Triggers> 
                                                    <Trigger Property="IsPressed" Value="True"
                                                        <Setter Property="Background" TargetName="border"
                                                            <Setter.Value> 
                                                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"
                                                                    <GradientStop Color="#7FFFFFFF" Offset="0"/> 
                                                                    <GradientStop Color="#33FFFFFF" Offset="1"/> 
                                                                    <GradientStop Color="#4CFFFFFF" Offset="0.5"/> 
                                                                    <GradientStop Color="#00FFFFFF" Offset="0.504"/> 
                                                                </LinearGradientBrush> 
                                                            </Setter.Value> 
                                                        </Setter> 
                                                        <Setter Property="Background" TargetName="border1" Value="#FF8A9EC6"/> 
                                                    </Trigger> 
                                                    <Trigger Property="IsEnabled" Value="False"
                                                        <Setter Property="Foreground" Value="#FFADADAD"/> 
                                                        <Setter Property="Opacity" TargetName="contentPresenter" Value="0.2"/> 
                                                        <Setter Property="Background" TargetName="border"
                                                            <Setter.Value> 
                                                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"
                                                                    <GradientStop Color="#7FFFFFFF" Offset="0"/> 
                                                                    <GradientStop Color="#33FFFFFF" Offset="1"/> 
                                                                    <GradientStop Color="#00FFFFFF" Offset="0.549"/> 
                                                                    <GradientStop Color="#33FFFFFF" Offset="0.527"/> 
                                                                </LinearGradientBrush> 
                                                            </Setter.Value> 
                                                        </Setter> 
                                                    </Trigger> 
                                                </ControlTemplate.Triggers> 
                                            </ControlTemplate> 
                                        </Setter.Value> 
                                    </Setter> 
                                </Style> 
                            </telerik:ClearFilterButton.Style> 
                        </telerik:ClearFilterButton> 
                        <telerik:CheckBoxList HorizontalAlignment="Stretch" MaxHeight="500" x:Name="listDistinctValues" Foreground="#FF000000" FilterDescription="{Binding Path=FilterDescription, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type telerik:DistinctFilterControl}}}"/> 
                    </StackPanel> 
                </Border> 
            </Border> 
        </telerik:GridViewFilteringPopup> 
    </StackPanel> 
     
</ControlTemplate> 
 

3 Answers, 1 is accepted

Sort by
0
Accepted
Atanas
Telerik team
answered on 21 Oct 2008, 04:15 PM
Hi Doug Yoder,

I managed to apply your control template for our DistinctFilterControl.  This was the problematic piece of xaml:

<telerik:CheckBoxList HorizontalAlignment="Stretch" MaxHeight="500" x:Name="listDistinctValues" Foreground="#FF000000" FilterDescription="{Binding Path=FilterDescription, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type telerik:DistinctFilterControl}}}"/> 

You missed to set a value for the ItemsSource property, in our template it looks like this:

ItemsSource="{TemplateBinding DistinctValues}" 



I am attaching you an example applying your template.

Kind regards,
Atanas
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Doug Yoder
Top achievements
Rank 2
answered on 21 Oct 2008, 04:21 PM
Great, thank you!  Do you have any idea why Blend wouldn't have included that when I created a copy of the default template?
0
Atanas
Telerik team
answered on 22 Oct 2008, 12:27 PM
Hello Doug Yoder,

Currently our CheckBoxList control inherits the Microsft's ListBox, using the Reflector I found out that the ListBox control is marked with this attribute:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Bindable(true), CustomCategory("Content")]

Actually this is the reason you do not see the ItemsSource property in Blend.

We are planning to rework the CheckBoxList control and it will no longer inherits ListBox, but this is most likely going to happen for Q1 2009.


Regards,
Atanas
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Doug Yoder
Top achievements
Rank 2
Answers by
Atanas
Telerik team
Doug Yoder
Top achievements
Rank 2
Share this question
or