Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPF VB.NET
Hi,
 
I'd like to create a table to show which user has which software opened in their system.
 
To show if the user has the software or not, I'd like to create an ellipsis that would be colored green if true and red if false.
 
I should have no problem with the code, what i'm now trying to figure out (since i've never used WPF before) is the best approach.
 
I think I should create a data grid to have optimal control over the look of the grid itself, as i want the lines of the grid to appear. However, datagrids don't allow me to insert ellipsis in their cells.
 
I then tried using the Grid, which works great, but I found no possible way to customize the appearance of the grid lines. I can only find the option to show or not show grid lines, and I would like to specify color, width, style, etc.
 
So what should I do? Any suggestions?
 
Thanks
Posted 22-Feb-13 10:19am
Comments
Sergey Alexandrovich Kryukov at 22-Feb-13 15:33pm
   
So, ellipsis or ellipse? These two things are totally unrelated. In principle, in WPF you can use them both, in any content, even in a grid view :-)
—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi.you can do following.your DataGridColumn must be like:
<DataGridTemplateColumn Header="Status">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button>
                                <Button.Template>
                                    <ControlTemplate TargetType="{x:Type Button}">
                                        <Ellipse Fill="{TemplateBinding Background}" Width="10" Height="10"/>
                                    </ControlTemplate>
                                </Button.Template>
                                <Button.Style>
                                    <Style TargetType="{x:Type Button}">
                                        <EventSetter Event="Button.Loaded" Handler="StatusButtonHandler"/>
                                    </Style>
                                </Button.Style>
                            </Button>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
 
and in your codeBehind you can define a property for checking the status of users' software.
in here i define a IsLoad property:
 
private void StatusButtonHandler(object sender, RoutedEventArgs e)
        {
            Button source = e.OriginalSource as Button;
            if (this.IsLoad == true)
            {
                source.Background = Brushes.Green;
            }
            else
            {
                source.Background = Brushes.Red;
            }
        }
 
my IsLoad property:
public bool IsLoad
       {
           get;
           set;
       }
 
I hope this help you.
Good Luck
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi. i credate a DataGridCheckBoxColumn.this is more professional:
<DataGridCheckBoxColumn Binding="{Binding IsFlagged}">
                                <DataGridCheckBoxColumn.HeaderTemplate>
                                    <DataTemplate >
                                        <Image Source="/Images/BlueFlag.png" Width="24" Height="24"/>
                                    </DataTemplate>
                                </DataGridCheckBoxColumn.HeaderTemplate>
                                <DataGridCheckBoxColumn.ElementStyle>
                                    <Style TargetType="{x:Type CheckBox}">
                                        <Setter Property="Height" Value="10"/>
                                        <Setter Property="Width" Value="10"/>
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="{x:Type CheckBox}">
                                                    <Ellipse x:Name="FlagEllipse" Fill="LightGray" Width="10" Height="10"/>
                                                    <ControlTemplate.Triggers>
                                                        <Trigger Property="IsChecked" Value="True">
                                                            <Setter TargetName="FlagEllipse" Property="Fill" Value="Red"/>
                                                        </Trigger>
                                                    </ControlTemplate.Triggers>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </DataGridCheckBoxColumn.ElementStyle>
                            </DataGridCheckBoxColumn>
 
"IsFlagged " is your property for checking.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 539
1 Maciej Los 300
2 DamithSL 233
3 Sergey Alexandrovich Kryukov 209
4 BillWoodruff 200
0 OriginalGriff 7,168
1 Sergey Alexandrovich Kryukov 6,377
2 DamithSL 5,461
3 Manas Bhardwaj 4,876
4 Maciej Los 4,450


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 23 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100