Search Results

Search found 3 results on 1 pages for 'jehof'.

Page 1/1 | 1 

  • Binding "Text-Property" of a derived textbox to another textbox doesn´t work

    - by Jehof
    Hello, i have a class 'MyTextBox' that derives from the default TextBox in Silverlight. This class currently contains no additional code. I set up a binding in xaml to bind the Text-Property of MyTextbox to another Textbox to reflect the input made in the Textbox. The effect is that MyTextBox doesn´t update and not display the text of the other Textbox. Additional i made an equal binding for a normal Textbox. And this works. Here´s the XAML for the bindings. <UserControl x:Class="Silverlight.Sample.Dummy" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:my="clr-namespace:Sample" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> <StackPanel x:Name="LayoutRoot" Background="White"> <TextBox Height="23" x:Name="textBox2" Width="120" /> <TextBox Text="{Binding ElementName=textBox2, Path=Text, Mode=TwoWay}" Width="120" /> <my:NumberTextBox Width="120" Text="{Binding ElementName=textBox2, Path=Text, Mode=OneWay}" /> </StackPanel> Is there something special to set for binding, when i derive from a control. PS: I tried a binding to a dummy object with INotifyPropertyChanged and set it as DataContext for the existing Textboxes. This test works as expected and my derived textbox gets updated.

    Read the article

  • Derive abstract class from non-abstract class

    - by Jehof
    Is it OK to derive an abstract class from a non-abstract class or is there something wrong with this approach? Here´s a little example: public class Task { // Some Members } public abstract class PeriodicalTask : Task { // Represents a base class for task that has to be done periodicaly. // Some additional Members } public class DailyTask : PeriodicalTask { // Represents a Task that has to be done daily. // Some additional Members } public class WeeklyTask : PeriodicalTask { // Represents a Task that has to be done weekly. // Some additional Members } In the example above i do not want to make the class Task abstract, because i want to instantiate it directly. PeriodicalTask should inherit the functionality from Task and add some additional members but i do not want to instantiate it directly. Only derived class of PeriodicalTask should be instantiated.

    Read the article

  • Reusable non generic method for generic methods

    - by Jehof
    I have the following base interface public interface IHandler{ void Handle(IMessage message); } and an generic interface inheriting the base interface public interface IHandler<TMessage> : IHandler where TMessage : IMessage{ void Handle(TMessage message); } My classes can implement the interface IHandler<TMessage> mutiple times. IMessage is an base interface for messages and isn´t relevant here. Currently i´m implementing the interfaces as follows. public class ExampleHandler : IHandler<ExampleMessage>, IHandler<OtherExampleMessag>{ void IHandler.Handle(IMessage message){ ExampleMessage example = message as ExampleMessage; if (example != null) { Handle(example); } else { OtherExampleMessage otherExample = message as OtherExampleMessage; if (otherExample != null) { Handle(otherExample); } } public void Handle(ExampleMessage) { //handle message; } public void Handle(OtherExampleMessage) { //handle message; } } What bothers me is the way i have to implement the Handle(IMessage) method, cause in my opinion its many redundant code, and i have to extend the method each time when i implement a new IHandler<TMessage> interface on my class. What i´m looking for is a more generic way to implement the Handle(IMessage) method (maybe in a base class for Handlers), but i´m currently stuck how to do that.

    Read the article

1