Click here to Skip to main content
15,911,141 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Design an analysis Program Pin
Lisa Z. Morgan23-Feb-11 5:58
Lisa Z. Morgan23-Feb-11 5:58 
QuestionHow to display a particular controls after user selection of a data from a combobox.. Pin
Rocky2321-Feb-11 20:03
Rocky2321-Feb-11 20:03 
AnswerRe: How to display a particular controls after user selection of a data from a combobox.. Pin
Mycroft Holmes21-Feb-11 21:15
professionalMycroft Holmes21-Feb-11 21:15 
GeneralRe: How to display a particular controls after user selection of a data from a combobox.. Pin
Rocky2321-Feb-11 22:29
Rocky2321-Feb-11 22:29 
GeneralRe: How to display a particular controls after user selection of a data from a combobox.. Pin
Mycroft Holmes21-Feb-11 23:58
professionalMycroft Holmes21-Feb-11 23:58 
AnswerRe: How to display a particular controls after user selection of a data from a combobox.. Pin
Jammer22-Feb-11 23:41
Jammer22-Feb-11 23:41 
QuestionWPF RoutedEvent not firing Pin
GreatBigYetti21-Feb-11 13:01
GreatBigYetti21-Feb-11 13:01 
AnswerRe: WPF RoutedEvent not firing Pin
GreatBigYetti23-Feb-11 1:28
GreatBigYetti23-Feb-11 1:28 
QuestionMSDN Silverlight Webcast feeds from 2008! Pin
RobCroll21-Feb-11 11:32
RobCroll21-Feb-11 11:32 
AnswerRe: MSDN Silverlight Webcast feeds from 2008! Pin
Abhinav S21-Feb-11 18:28
Abhinav S21-Feb-11 18:28 
GeneralRe: MSDN Silverlight Webcast feeds from 2008! Pin
RobCroll21-Feb-11 19:19
RobCroll21-Feb-11 19:19 
Questionpitch circle Pin
pet220-Feb-11 20:31
pet220-Feb-11 20:31 
AnswerRe: pitch circle Pin
Abhinav S20-Feb-11 21:00
Abhinav S20-Feb-11 21:00 
QuestionSilverlight drawing functions Pin
bruno.picardi19-Feb-11 0:19
bruno.picardi19-Feb-11 0:19 
AnswerRe: Silverlight drawing functions Pin
SledgeHammer0119-Feb-11 5:59
SledgeHammer0119-Feb-11 5:59 
GeneralRe: Silverlight drawing functions Pin
bruno.picardi19-Feb-11 20:55
bruno.picardi19-Feb-11 20:55 
GeneralRe: Silverlight drawing functions Pin
SledgeHammer0120-Feb-11 6:15
SledgeHammer0120-Feb-11 6:15 
AnswerRe: Silverlight drawing functions Pin
Abhinav S19-Feb-11 6:51
Abhinav S19-Feb-11 6:51 
AnswerRe: Silverlight drawing functions Pin
RobCroll21-Feb-11 2:35
RobCroll21-Feb-11 2:35 
GeneralRe: Silverlight drawing functions Pin
bruno.picardi21-Feb-11 19:55
bruno.picardi21-Feb-11 19:55 
QuestionAdd a class instance that has a DataTemplate defining the class' visual appearance Pin
JimLaVine18-Feb-11 12:08
JimLaVine18-Feb-11 12:08 
I have the following class
namespace WpfDataTemplate
{
    public class Rung : UIElement
    {
        public int RungNumber { get; set; }
    }
}


and the following XAML
<Window x:Class="WpfDataTemplate.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:local="clr-namespace:WpfDataTemplate" 
        Title="MainWindow" Height="350" Width="525">
    <StackPanel>
        <StackPanel.Resources>
            <DataTemplate DataType="{x:Type local:Rung}">
                <Grid VerticalAlignment="Top" MinHeight="60" MinWidth="175">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="75"/>
                        <ColumnDefinition MinWidth="175"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="0" x:Name="number" Text="{Binding RungNumber}"
                               HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    <Path x:Name="LeftRail" Data="M0,0 L0,60" Stretch="Fill" Stroke="Blue" Width="1" HorizontalAlignment="Left" Grid.Column="1"/>
                    <Path x:Name="RightRail" Data="M0,0 L0,60" Stretch="Fill" Stroke="Blue" Width="1" HorizontalAlignment="Right" Grid.Column="1" Margin="0,0,10,0" />
                    <Path x:Name="Run" Data="M0,0 L10,0" Height="1" Stretch="Fill" Stroke="Blue" Grid.Column="1" VerticalAlignment="Top" Margin="0,30,10,0"/>
                </Grid>
            </DataTemplate>
            <local:Rung x:Key="newRung" />
        </StackPanel.Resources>

            <StackPanel Height="50" Orientation="Horizontal">
                <Button Height="24" Content="Add Rung"/>
            </StackPanel>
            <ContentControl Content="{StaticResource newRung}"/>

    </StackPanel>
</Window>


I want to add a click handler to the button that will add an instance of the class to the MainWindow, but it doesn't work.
private void Button_Click(object sender, RoutedEventArgs e)
       {
           Rung r = new Rung {RungNumber = 1};
           RungSurface.Children.Add(r);
       }


Can anyone help?

Thanks,
Jim
AnswerRe: Add a class instance that has a DataTemplate defining the class' visual appearance Pin
RobCroll20-Feb-11 20:04
RobCroll20-Feb-11 20:04 
GeneralRe: Add a class instance that has a DataTemplate defining the class' visual appearance Pin
Mycroft Holmes20-Feb-11 20:22
professionalMycroft Holmes20-Feb-11 20:22 
GeneralRe: Add a class instance that has a DataTemplate defining the class' visual appearance Pin
RobCroll21-Feb-11 1:22
RobCroll21-Feb-11 1:22 
QuestionMax File Size in Isolated Storage? Pin
dbrenth18-Feb-11 9:28
dbrenth18-Feb-11 9:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.