Click here to Skip to main content
15,898,596 members
Home / Discussions / WPF
   

WPF

 
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 
AnswerRe: Max File Size in Isolated Storage? Pin
Steve Maier18-Feb-11 9:36
professionalSteve Maier18-Feb-11 9:36 
GeneralRe: Max File Size in Isolated Storage? Pin
dbrenth18-Feb-11 9:46
dbrenth18-Feb-11 9:46 
AnswerRe: Max File Size in Isolated Storage? Pin
dbrenth18-Feb-11 10:32
dbrenth18-Feb-11 10:32 
GeneralRe: Max File Size in Isolated Storage? Pin
Abhinav S20-Feb-11 17:53
Abhinav S20-Feb-11 17:53 
QuestionXmlDocument Pin
arkiboys18-Feb-11 5:26
arkiboys18-Feb-11 5:26 
AnswerRe: XmlDocument Pin
Abhinav S18-Feb-11 6:12
Abhinav S18-Feb-11 6:12 
GeneralRe: XmlDocument Pin
#realJSOP19-Feb-11 2:35
professional#realJSOP19-Feb-11 2:35 
AnswerRe: XmlDocument Pin
#realJSOP19-Feb-11 2:34
professional#realJSOP19-Feb-11 2:34 
GeneralRe: XmlDocument Pin
Abhinav S19-Feb-11 3:14
Abhinav S19-Feb-11 3:14 
QuestionAccess xml file from .xaml page Pin
arkiboys18-Feb-11 5:16
arkiboys18-Feb-11 5:16 
AnswerRe: Access xml file from .xaml page Pin
Abhinav S18-Feb-11 6:24
Abhinav S18-Feb-11 6:24 
QuestionMVVM: Best Practices and Design Patterns Pin
IngoVals18-Feb-11 4:54
IngoVals18-Feb-11 4:54 
AnswerRe: MVVM: Best Practices and Design Patterns Pin
Abhinav S18-Feb-11 6:20
Abhinav S18-Feb-11 6:20 

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.