Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3303468
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:57:37+00:00 2026-05-17T20:57:37+00:00

If I have the following DataGrid, how would I go about binding the Visibility

  • 0

If I have the following DataGrid, how would I go about binding the Visibility of the TemplateColumn to a property on my ViewModel? The code I have here is based on a recommendation from this SO Question but no luck.

            <sdk:DataGrid Visibility="{Binding GridVisible}" DataContext="{Binding}" Grid.Row="1" ItemsSource="{Binding Path=BookSource}" x:Name="bookGrid" AutoGenerateColumns="False" IsReadOnly="True">
                <sdk:DataGrid.Columns>
                    <sdk:DataGridTemplateColumn Visibility="{Binding Path=DataContext.GridImgColumnVisible, ElementName=bookGrid}">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Image Stretch="Fill" Source="{Binding Path=SmallImgURI}"></Image>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>

                    <sdk:DataGridTextColumn Header="Title"  Width="*"  Binding="{Binding CurrentBook.Title}" />
                    <sdk:DataGridTextColumn Header="Published" Width="150"  Binding="{Binding CurrentBook.Published, StringFormat=d}" />
                </sdk:DataGrid.Columns>
            </sdk:DataGrid>

EDIT – I’ve also tried:

<sdk:DataGridTemplateColumn Visibility="{Binding Path=DataContext.GridImgColumnVisible, ElementName=root}">

and I’ve also added a button to my actual control, and bound its visibility to this property without difficulty.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:57:37+00:00Added an answer on May 17, 2026 at 8:57 pm

    It can be achieved in WPF, but Silverlight DataGrid is different. Visibility property isn’t dependency property (you can’t perform binding), Columns aren’t belong to VisualTree and don’t inherit DataContext.

    Use code-behind, something like this:

    var model = (MyViewModel)this.DataContext;
    model.PropertyChanged += (s,e) => 
    {
        if(e.PropertyName == "GridImgColumnVisible")
            this.UpdateGridColumnVisibility(model.GridImgColumnVisible);
    };
    
    public void UpdateGridColumnVisibility(Visibility imageVisibility)
    {
        var imgColumn = bookGrid.Columns.Cast<DataGridColumn>().FirstOrDefault(c => ((string)c.GetValue(Panel.NameProperty)) == "imgColumn");
        if(imgColumn != null)
            imgColumn.Visibility = imageVisibility;
    }
    

    And add the name to the column:

    <sdk:DataGridTemplateColumn x:Name="imgColumn">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code that refreshes the datagrid in the form after the
I have the following scenario : A Flex 3 DataGrid is sitting here At
I have the following code: <DataTemplate> <!--<sdk:DataGridTextColumn Binding={Binding Description} Header=Description Width=205 />--> <TextBlock Text={Binding
I have the following XAML Code: <sdk:DataGrid Margin=58,8,52,18 Name=dataGridTickets> <sdk:DataGrid.Columns> <sdk:DataGridTextColumn x:Name=ticketNoColumn Header=Ticket No.
I have the following code: public interface IMyInterface { DataGrid ItemsInGrid { get; set;
I would like the following functionality: I have a datagrid, and when I go
I have following DataGrid in wpf. <DataGrid AutoGenerateColumns=False Grid.Row=1 Name=adsGrid ItemsSource={Binding Path=Ads} CanUserAddRows=False CanUserDeleteRows=False
I have the following scenario, I want to create a DataGrid and then populate
I have following code: <div class='parent'> <div class='left-child'></div> <div class=right-child></div> </div> What I want
Following on from this initial investigations on Silverlight architectures, I have some new requirements

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.