CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2005
    Posts
    180

    How do I add .CS functionality to XAML classes built in Expression Design?

    How do I add .CS functionality to XAML classes built in Expression Design?

    I have a Silverlight project handed to me by designers that does not seem to have much functionalty to it yet. One of the first things I have noticed is that there does not seem to be any corresponding .cs files that match up with what appears to be children of the "LayoutRoot". I mean, as it appears in Expression Blend, these are child nodes in the "Objects and Timeline Tab" under "LayoutRoot".

    When viewed in Visual Studio 8, they appear to be <Grid> children nodes of <Grid x:Name="LayoutRoot" Background="Black"> of the Page.xaml class. Shouldn't the first step be that I generate some .cs files or class to handle the functionality of these grids? I did a search on the name of the first child grid and I did not get any results in any of the existing .cs files. How do I generate .cs files?

  2. #2
    Join Date
    Dec 2005
    Posts
    180

    Re: How do I add .CS functionality to XAML classes built in Expression Design?

    In the project panel of Expression Blend, there are .xaml and associated xaml.cs files for some navagation buttons but not for the<grid> classes.

    I assume now that what I need to do is open Expression Design to generate the .xaml.cs files. If I do, how do I do it? What file should I input? Do I use the page.xaml file?

  3. #3
    Join Date
    Nov 2007
    Location
    .NET 3.5 / VS2008 Developer
    Posts
    624

    Re: How do I add .CS functionality to XAML classes built in Expression Design?

    The Grid is commonly used as a container control for the entire page. You normally don't deal with it directly. If you have controls in the grid, you deal with those controls. Give them names(ie.. x:Name="someName"), then deal with the events for those controls. It's almost exactly like WinForms in regards to controls and dealing with events.

    For example, here is some XAML from a WPF project(I know it's not Silverlight but basically the same)

    XAML
    Code:
    <Grid x:Name="LayoutRoot">
        <Canvas 
            x:Name="canvas1" 
            Height="100" 
            HorizontalAlignment="Left" 
            Margin="116,62,0,0" 
            VerticalAlignment="Top" 
            Width="200">
                
        </Canvas>
            
        <Button 
            x:Name="btnGetChildren" 
            Content="Get Children" 
            Height="23" 
            Margin="174,209,218,47" 
            Width="75" 
            Click="btnGetChildren_Click" />
    </Grid>
    Notice that I have a Canvas and a Button "inside" the Grid. Notice that the button has a Click event that I am handling. The code for that click event is in the "xaml.cs" file for the page.
    ===============================
    My Blog

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

Featured