how to access the grids on silverlight

I have a button called test button an when I click on it I want to show a grid whose visbility is set to 0

I created a mouse button event (below) but my Grid (testGrid) is not available in the project.

private void testButton(object sender, System.Windows.Input.MouseButtonEventArgs e) { testGrid.Opacity = 1; }

it highlights testGrid red

new to SL so not sure whats going on here

** EDIT **

xml for the Grid

<Grid x:Name="testGrid" HorizontalAlignment="Left" Width="150" Margin="950,-77,0,0" Height="77" VerticalAlignment="Top" Opacity="0"> </Grid> <Image x:Name="testButton" HorizontalAlignment="Right" Margin="0,1,180,3" Stretch="Fill" Width="53" Height="49" Cursor="Hand" Opacity="0.8" >

-------------Problems Reply------------

try this: On XAML

<Grid x:Name="testGrid" HorizontalAlignment="Left" Width="150" Margin="950,-77,0,0" Height="77" VerticalAlignment="Top" Opacity="0">
<Image x:Name="testButton" HorizontalAlignment="Right" Margin="0,1,180,3" Stretch="Fill" Width="53" Height="49" Cursor="Hand" Opacity="0.8" MouseLeftButtonDown="testButton" />

on the cs

private void testButton(object sender, System.Windows.Input.MouseButtonEventArgs e){
testGrid.Visibility = Visibility.Visible;

The reason that your grid might not be accessibly in the .cs file is if you have changed the class name in the .cs file, but not in the Xaml directive at the top of your .xaml file.

If these two mis match, visual studio won't be able to link up the two files and so you wouldn't be able to see the grid control in the code behind.

Other items with your code to consider:

Though Opacity will work an alternative I use more often is:

This will show the grid.

testGrid.Visibility = Visibility.Visible;

This will hide the grid.

testGrid.Visibility = Visibility.Collapsed;

Also, Your "Button" is an Image tag and not a button. It is an image with the same name as the method you are trying to call. You will either need to change your Image to allow for an on click event or change it to a button, something like

<Button Click="TestBUtton" Text="MyButton" />

And I'd enter that in the Xaml directly so that when you type in the click event handler it auto generates the method in the code behind for you.

Category:silverlight Views:0 Time:2011-11-23

Related post

  • Access ExtJS grid's column model from other file 2009-06-18

    I have an ExtJS grid that has a button set up in it. The button triggers a function that's defined into other JS file that's included in the grid page. The function triggers ok but in that function I want to get the columns count like this: grid.getC

  • How i can use local ms-access db file in Silverlight 4 2010-05-27

    How i can use local ms-access db file in Silverlight 4. I want to read records from local ms-access file of any user who installed Out Of Browser Application on his/her system. Same as we do with excel records. Looking forward to get results from exp

  • how to bind images to grid in silverlight? 2010-07-17

    can u give sample example code for how to bind images to grid in silverlight? --------------Solutions------------- This article should give you some ideas: Display Images from a Database in a Silverlight DataGrid Control

  • Problem accessing localhost URI from Silverlight 2010-10-09

    (repost because of SO outage; apologies if the other one re-appears) I'm building a Silverlight app that will run on Azure. My VS solution has two projects: the web role and the Silverlight. The web role has a Service that works. (I can go to localho

  • Why do you need webservices to access a database from Silverlight? 2011-04-22

    I am at the moment looking into several options to create a new app which can be accessed using the browser by multiple user in a closed intranet. I thought about using Silverlight for its user-friendliness and its WPF design so close to the rich cli

  • Changing the look and feel (like 3d effect) of grids in silverlight 2011-06-09

    Is it possible to change the look of the data grid in silverlight (or any other object), by look i mean changing the depth or the effect of it so it looks 3d like and stands out? Thanks, Michelle --------------Solutions------------- You can change th

  • How to access a grid inside of a RichTextBox in Silverlight 4? 2010-04-21

    I am trying to allow a user to create a table inside of a RichTextBox. I can create a Grid inside of the RichTextBox, but I am having some issues with it. I start with this XAML in the Grid. <RichTextBox Name="TB1" AcceptsReturn="True"> <Par

  • Error accessing RSS feed from Silverlight with WebClient() 2009-01-30

    I'm downloaded the code from John Papa's book here: and am sucessfully running the Chapter 7 example which allows you to press a button and it reads RSS from and then displays it. So, then I replaced the digg URL

  • Direct Access to SQL with Silverlight 2009-06-26

    I am new to .NET in general, so I hope this isn't too n00b of a question. I'm looking to write a Silverlight app that interacts with a MSSQL DB using LINQ. Do I absolutely, positively have to use a seperate WCF service? It seems there are security im

  • How to access application object in Silverlight class library? 2009-09-02

    Suppose my solution have two project: myApp: silverlight application project: the default application App MyLib: silverlight class library project then in code for those controls in Mylib, how to access the application object App? --------------Solut

  • Access Sharepoint webservice from Silverlight with specfic user credentials 2009-11-19

    I am accessing Sharepoint web services from a Silverlight application, I have put the clientaccesspolicy.xml file in the root of my Sharepoint site, so I can access fine. What I would like to do though is hard code the user credentials so the web ser

  • How to access Membership/roles through silverlight 2009-11-22

    I have a silverlight control on my mvc page, need to communicate with a webservice where i need to send the current role of the user logged into the system with. But how do I access the "Roles.GetRolesForUser()" from within my silverlight app

  • FloatableWindow resizes Grid in Silverlight 2010-03-12

    I'm trying to use Tim Heuer's FloatableWindow control for a non-modal options window in my Silverlight application. However, I'm running into a problem with the FloatableWindow resizing it's parent grid when it opens. For example, before I open the w

  • Binding to grids in silverlight 2010-04-21

    I've just begun learning Silverlight (though I have 3 years C# experience). I'm trying to output a grid that will be used in a work timetracking application. I have a list of objects, each object looks like this public class WorkItem { public int Tas

  • how to set the rounded inside corners of a grid in Silverlight 4 2010-04-25

    I need to set the rounded corners inside the grid control using silverlight 4. When I tried to do something like this: <Border BorderThickness="2" BorderBrush="#FF3EA9F5" Grid.Row="1" CornerRadius="5,5,0,0" Height="10" VerticalAlignment="Bottom"

  • Access external data from Silverlight application running in a webpart in Sharepoint 2010 2010-06-03

    I can read the SP lists fine and pull data out of the SP context, but I am trying to get data from an external database as well and I don't know exactly how to do that. Is is possible to add WCF communication to the webpart that will allow the Silver

  • Master detail grid in Silverlight 4 - No headers for Detail grid 2010-07-08

    I'm developing a Silverlight application where I want the master and its detail grid to share the same columns. So, some of the common fields would be displayed in master grid and rest of the fields would be specific for each child/detail. How can I

  • Access local dll with SilverLight 4 out-of-browser 2010-11-18

    I read a little about the new features of Silverlight 4 and it seems possible to 'access' microsoft office . Does this mean that we can reference local dll and COMs ? Thanks --------------Solutions------------- You don't reference dlls but you can ac

  • Error accessing project resource from Silverlight Test project 2011-01-15

    I am doing unit tests for Silverlight 4 in Visual Studio 2010. The problem is I am not able to use resources added to test project. During test run when I try to access a resouce like this: [TestClass] public class Class1 { [TestMethod] public void T

Copyright (C), All Rights Reserved.

processed in 0.154 (s). 11 q(s)