Click here to Skip to main content
15,890,512 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: LINQ Pin
Pete O'Hanlon5-Aug-09 2:13
mvePete O'Hanlon5-Aug-09 2:13 
GeneralRe: LINQ Pin
sunil.n.cs5-Aug-09 3:11
sunil.n.cs5-Aug-09 3:11 
QuestionHow can I set my dynamic images in random position? Pin
Kunal Chowdhury «IN»3-Aug-09 21:13
professionalKunal Chowdhury «IN»3-Aug-09 21:13 
AnswerRe: How can I set my dynamic images in random position? Pin
Christian Graus3-Aug-09 22:47
protectorChristian Graus3-Aug-09 22:47 
QuestionHow i can add new buttons to my epander control Pin
wasimsharp3-Aug-09 20:40
wasimsharp3-Aug-09 20:40 
AnswerRe: How i can add new buttons to my epander control Pin
Super Lloyd4-Aug-09 0:47
Super Lloyd4-Aug-09 0:47 
GeneralRe: How i can add new buttons to my epander control Pin
wasimsharp4-Aug-09 1:27
wasimsharp4-Aug-09 1:27 
GeneralRe: How i can add new buttons to my epander control Pin
Super Lloyd4-Aug-09 1:40
Super Lloyd4-Aug-09 1:40 
This will probably work (I didn't scrutinize the code much).

However, to create really reusable control, adding an event handler on a button define in a template in the IsLoaded event is not the best approach.

1. slightly better is to add the event listener in OnApplyTemplate

2. much better is to have those button trigger a (public static) command (defined in the class).
And in the code, do not register event handler, instead add some command binding to handle the event.

For exemple, here is a snippet of my file picker control (note that I used a predefined ApplicationCommands.Open, but this can easily be replace by "public readonly static MyCommand = new RoutedCommand()")

-- (snippet) FilePicker.cs --
public class FilePicker : Control
{
    public FilePicker()
    {
        CommandBindings.Add(new CommandBinding(
            ApplicationCommands.Open,
            OnOpenCommand
            ));
    }

    private void OnOpenCommand(object sender, ExecutedRoutedEventArgs e)
    {
        // handle the event
    }


-- (snippet) FilePicker.generic.xaml --
<Style TargetType="{x:Type local:FilePicker}" x:Key="{x:Type local:FilePicker}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:FilePicker}">

                <DockPanel>
                    <Button DockPanel.Dock="Right" Content="..." MinWidth="20" Command="{x:Static ApplicationCommands.Open}"/>
                    <TextBox IsReadOnly="True" Text="{TemplateBinding FileName}" />
                </DockPanel>

            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>


A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.

AnswerRe: How i can add new buttons to my epander control Pin
wasimsharp4-Aug-09 1:56
wasimsharp4-Aug-09 1:56 
QuestionCustom classes in XAML - Assign properties after parents set Pin
Ian Shlasko3-Aug-09 4:15
Ian Shlasko3-Aug-09 4:15 
AnswerRe: Custom classes in XAML - Assign properties after parents set Pin
Super Lloyd4-Aug-09 3:14
Super Lloyd4-Aug-09 3:14 
GeneralRe: Custom classes in XAML - Assign properties after parents set Pin
Ian Shlasko4-Aug-09 12:14
Ian Shlasko4-Aug-09 12:14 
GeneralRe: Custom classes in XAML - Assign properties after parents set Pin
Super Lloyd4-Aug-09 13:06
Super Lloyd4-Aug-09 13:06 
GeneralRe: Custom classes in XAML - Assign properties after parents set Pin
Ian Shlasko4-Aug-09 15:57
Ian Shlasko4-Aug-09 15:57 
QuestionHow can I cache data in WPF application? Pin
Kunal Chowdhury «IN»3-Aug-09 1:06
professionalKunal Chowdhury «IN»3-Aug-09 1:06 
AnswerRe: How can I cache data in WPF application? Pin
Pete O'Hanlon3-Aug-09 1:32
mvePete O'Hanlon3-Aug-09 1:32 
AnswerRe: How can I cache data in WPF application? Pin
Kunal Chowdhury «IN»3-Aug-09 2:43
professionalKunal Chowdhury «IN»3-Aug-09 2:43 
QuestionHow to Give Header in multicolunm TreeView and also implement sorting algo? Pin
sachinjadhavcm2-Aug-09 23:54
sachinjadhavcm2-Aug-09 23:54 
QuestionAdjusting Panels in WPF programatically ? Pin
Krishna Aditya2-Aug-09 20:31
Krishna Aditya2-Aug-09 20:31 
AnswerRe: Adjusting Panels in WPF programatically ? Pin
Christian Graus2-Aug-09 22:02
protectorChristian Graus2-Aug-09 22:02 
QuestionGlobal Styles - Update Pin
#realJSOP2-Aug-09 1:02
mve#realJSOP2-Aug-09 1:02 
QuestionHow to display a document in silverlight? Pin
CBenac31-Jul-09 14:27
CBenac31-Jul-09 14:27 
AnswerRe: How to display a document in silverlight? Pin
Michael Sync31-Jul-09 18:21
Michael Sync31-Jul-09 18:21 
QuestionUse Themes? Pin
#realJSOP31-Jul-09 1:09
mve#realJSOP31-Jul-09 1:09 
AnswerRe: Use Themes? Pin
Super Lloyd31-Jul-09 1:52
Super Lloyd31-Jul-09 1:52 

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.