Click here to Skip to main content
12,066,222 members (47,253 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB 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 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web03 | 2.8.160207.1 | Last Updated 23 Feb 2013
Copyright © CodeProject, 1999-2016
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