Results 1 to 2 of 2

Thread: [RESOLVED] Checkbox Data Template

  1. #1

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    Resolved [RESOLVED] Checkbox Data Template

    Im changing the checkbox "checkbox" image based upon binding values triggered and all is fine but the initial image doesnt get set. It remains as a checkbox.

    I think its either the trigger or not the right way to mondify this or Im missing something.

    Ideas?


    xaml Code:
    1. <UserControl x:Class="Dev.Views.Controls.ProgressCheckBox"
    2.              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    3.              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    4.              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    5.              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    6.              x:Name="Root"
    7.              d:DesignHeight="300"
    8.              d:DesignWidth="300"
    9.              mc:Ignorable="d">
    10.     <UserControl.Resources>
    11.         <DataTemplate x:Key="NotStartedTempalte">
    12.             <!--<RadioButton Content=""
    13.                          IsChecked="True"
    14.                          IsEnabled="False" />-->
    15.             <Path x:Name="NotStartedTempalte"
    16.                   Width="15"
    17.                   Height="15"
    18.           Margin="2"
    19.                   Stretch="Fill"
    20.                   Stroke="Black"
    21.                   StrokeThickness="1.5" >
    22.                 <Path.Data>
    23.                     <RectangleGeometry Rect="40,40 30 30" />
    24.                 </Path.Data>
    25.             </Path>
    26.         </DataTemplate>
    27.         <DataTemplate x:Key="InProgressTemplate">
    28.             <Path x:Name="ArrowPath"
    29.                   Width="30"
    30.                   Height="15"
    31.                   Data="F1 M 358.447,332.449L 358.447,319.664L 380.875,319.664L 380.798,309.408L 407.698,326.505L 381.068,343.628L 380.982,332.45L 358.447,332.449 Z "
    32.                   Stretch="Fill"
    33.                   Stroke="Black"
    34.                   StrokeThickness="2" />
    35.         </DataTemplate>
    36.         <DataTemplate x:Key="CompleteTemplate">
    37.             <Path x:Name="CheckMark"
    38.                   Width="25"
    39.                   Height="25"
    40.                   Data="M 12.4227,0.00012207C 12.4867,0.126587 12.5333,0.274536 12.6787,0.321411C 9.49199,3.24792 6.704,6.57336 4.69865,10.6827C 4.04399,11.08 3.47066,11.5573 2.83199, 11.9706C 2.09467,10.2198 1.692,8.13196 3.8147e-006, 7.33606C 0.500004,6.79871 1.31733,6.05994 1.93067,6.2428C 2.85999,6.51868 3.14,7.9054 3.60399,8.81604C 5.80133, 5.5387 8.53734,2.19202 12.4227,0.00012207 Z "
    41.                   Fill="Black"
    42.                   SnapsToDevicePixels="False"
    43.                   Stretch="Fill"
    44.                   Stroke="Black"
    45.                   StrokeThickness="1" />
    46.         </DataTemplate>
    47.         <DataTemplate x:Key="ErrorTemplate">
    48.             <Path Width="15"
    49.                   Height="15"
    50.                   Margin="2"
    51.                   Data="F1M54.0573,47.8776L38.1771,31.9974 54.0547,16.1198C55.7604,14.4141 55.7604,11.6511 54.0573,9.94531 52.3516,8.23962 49.5859,8.23962 47.8802,9.94531L32.0026,25.8229 16.1224,9.94531C14.4167,8.23962 11.6511,8.23962 9.94794,9.94531 8.24219,11.6511 8.24219,14.4141 9.94794,16.1198L25.8255,32 9.94794,47.8776C8.24219,49.5834 8.24219,52.3477 9.94794,54.0534 11.6511,55.7572 14.4167,55.7585 16.1224,54.0534L32.0026,38.1745 47.8802,54.0534C49.5859,55.7585 52.3516,55.7572 54.0573,54.0534 55.7604,52.3477 55.763,49.5834 54.0573,47.8776z"
    52.                   Fill="Red"
    53.                   RenderTransformOrigin="0.5,0.5"
    54.                   Stretch="Uniform" />
    55.         </DataTemplate>
    56.         <ControlTemplate x:Key="CheckBoxTemplate" TargetType="ContentControl">
    57.             <ContentControl Name="Content" />
    58.             <ControlTemplate.Triggers>
    59.                 <DataTrigger Binding="{Binding ProgressCheckMode, ElementName=Root}" Value="Complete">
    60.                     <Setter TargetName="Content" Property="ContentTemplate" Value="{StaticResource CompleteTemplate}" />
    61.                 </DataTrigger>
    62.                 <DataTrigger Binding="{Binding ProgressCheckMode, ElementName=Root}" Value="InProgress">
    63.                     <Setter TargetName="Content" Property="ContentTemplate" Value="{StaticResource InProgressTemplate}" />
    64.                 </DataTrigger>
    65.                 <DataTrigger Binding="{Binding ProgressCheckMode, ElementName=Root}" Value="NotStarted">
    66.                     <Setter TargetName="Content" Property="ContentTemplate" Value="{StaticResource NotStartedTempalte}" />
    67.                 </DataTrigger>
    68.                 <DataTrigger Binding="{Binding ProgressCheckMode, ElementName=Root}" Value="Error">
    69.                     <Setter TargetName="Content" Property="ContentTemplate" Value="{StaticResource ErrorTemplate}" />
    70.                 </DataTrigger>
    71.                 <DataTrigger Binding="{Binding IsRunning, ElementName=Root}" Value="False">
    72.                     <Setter Property="Visibility" Value="Hidden" />
    73.                 </DataTrigger>
    74.             </ControlTemplate.Triggers>
    75.         </ControlTemplate>
    76.  
    77.         <Style x:Key="CheckboxVisibilityStyle" TargetType="RadioButton">
    78.             <Style.Triggers>
    79.                 <DataTrigger Binding="{Binding IsRunning, ElementName=Root}" Value="True">
    80.                     <Setter Property="Visibility" Value="Collapsed" />
    81.                 </DataTrigger>
    82.             </Style.Triggers>
    83.         </Style>
    84.     </UserControl.Resources>
    85.     <Grid>
    86.         <Grid.ColumnDefinitions>
    87.             <ColumnDefinition Width="40" />
    88.             <ColumnDefinition />
    89.         </Grid.ColumnDefinitions>
    90.         <RadioButton HorizontalAlignment="Center"
    91.                      VerticalAlignment="Center"
    92.                      IsChecked="False"
    93.                      Style="{StaticResource CheckboxVisibilityStyle}" />
    94.         <ContentControl Grid.Column="0"
    95.                         HorizontalAlignment="Center"
    96.                         VerticalAlignment="Center"
    97.                         Template="{StaticResource CheckBoxTemplate}" />
    98.         <TextBlock Grid.Column="1"
    99.                    HorizontalAlignment="Left"
    100.                    VerticalAlignment="Center"
    101.                    Text="{Binding Text,
    102.                                   ElementName=Root}" />
    103.     </Grid>
    104. </UserControl>
    Attached Images Attached Images    
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  2. #2

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    Re: Checkbox Data Template

    Figured out what they had done and how to fix it.
    They had the style set to a radio button but the resources mixed between radio button and checkbox. I added override for teh checkbox template which I posted below and it all linked up.



    xaml Code:
    1. <Style x:Key="CheckboxVisibilityStyle" TargetType="CheckBox">
    2.             <Setter Property="OverridesDefaultStyle" Value="true" />
    3.             <Setter Property="Template">
    4.                 <Setter.Value>
    5.                     <ControlTemplate TargetType="{x:Type CheckBox}">
    6.                         <BulletDecorator Background="Transparent">
    7.                             <BulletDecorator.Bullet>
    8.                                 <Path x:Name="NotStartedTempalte"
    9.                                     Width="15"
    10.                                     Height="15"
    11.                                     Margin="2"
    12.                                     Stretch="Fill"
    13.                                     Stroke="Black"
    14.                                     StrokeThickness="1.5" >
    15.                                     <Path.Data>
    16.                                         <RectangleGeometry Rect="40,40 30 30" />
    17.                                     </Path.Data>
    18.                                 </Path>
    19.                             </BulletDecorator.Bullet>
    20.                         </BulletDecorator>
    21.                     </ControlTemplate>
    22.                 </Setter.Value>
    23.             </Setter>
    24.             <Style.Triggers>
    25.                 <DataTrigger Binding="{Binding IsRunning, ElementName=Root}" Value="True">
    26.                     <Setter Property="Visibility" Value="Collapsed" />
    27.                 </DataTrigger>
    28.             </Style.Triggers>
    29.         </Style>
    Attached Images Attached Images  
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width