Click here to Skip to main content
15,886,919 members
Home / Discussions / WPF
   

WPF

 
QuestionXmlWriter Pin
Ranger4923-Mar-09 22:28
Ranger4923-Mar-09 22:28 
AnswerRe: XmlWriter Pin
Ranger4923-Mar-09 23:42
Ranger4923-Mar-09 23:42 
GeneralRe: XmlWriter Pin
Ranger4924-Mar-09 4:02
Ranger4924-Mar-09 4:02 
GeneralRe: XmlWriter Pin
Mark Salsbery24-Mar-09 6:17
Mark Salsbery24-Mar-09 6:17 
GeneralRe: XmlWriter Pin
Ranger4924-Mar-09 6:22
Ranger4924-Mar-09 6:22 
GeneralRe: XmlWriter Pin
Mark Salsbery24-Mar-09 6:34
Mark Salsbery24-Mar-09 6:34 
GeneralRe: XmlWriter Pin
Ranger4924-Mar-09 6:41
Ranger4924-Mar-09 6:41 
QuestionRoutingStrategy doesn't work:confused: Pin
mildred-frontfree23-Mar-09 21:04
mildred-frontfree23-Mar-09 21:04 
Thanks ABitSmart And Pete for your answers. I am trying to use RoutedEvent correctly this time. But the RoutingStrategy doesn't work.

MyButtonSimple class has a RoutedEvent which RoutingStrategy is Tunnel.

public class MyButtonSimple: Button
{
// Create a custom routed event by first registering a RoutedEventID
// This event uses the bubbling routing strategy
public static readonly RoutedEvent TapEvent = EventManager.RegisterRoutedEvent(
"Tap", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MyButtonSimple));

// Provide CLR accessors for the event
public event RoutedEventHandler Tap
{
add { AddHandler(TapEvent, value); }
remove { RemoveHandler(TapEvent, value); }
}

public MyButtonSimple()
{
this.Tap += new RoutedEventHandler(MyButtonSimple_Tap);
}

//Handle the TapEvent
void MyButtonSimple_Tap(object sender, RoutedEventArgs e)
{
Debug.WriteLine("Tag:"+this.Tag.ToString());
}
}

Then I have a Window1 to test MyButtonSimple like this

<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1"
Width="300"
Height="300">
<local:MyButtonSimple Width="80"
Height="80"
Tag="OuterButton">
<Canvas Width="60"
Height="60"
PreviewMouseDown="Canvas_PreviewMouseDown">
<local:MyButtonSimple Width="20"
Height="20"
Tag="InnerButton"/>
</Canvas>
</local:MyButtonSimple>
</Window>

private void Canvas_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
RoutedEventArgs newEventArgs = new RoutedEventArgs(MyButtonSimple.TagEvent);
(sender as Canvas).RaiseEvent(newEventArgs);
}


Well, just as my anticipation, the output window printed "OutterButton". But when I change the RoutingStrategy to RoutingStrategy.Tunnel, which I anticipate to raise the InnerButton ,the output window still printed "OutterButton".
Is it against the routed mechanism? And Many ways I've tried since then(such as raise the event in Canvas_MouseDown), it still printed "OutterButton". And what I wanna see is "InnerButton".
Am I doing wrong angain or the RoutingStrategy doesn't work this way?
AnswerRe: RoutingStrategy doesn't work:confused: Pin
ABitSmart23-Mar-09 22:44
ABitSmart23-Mar-09 22:44 
GeneralRe: RoutingStrategy doesn't work:confused: Pin
mildred-frontfree23-Mar-09 23:10
mildred-frontfree23-Mar-09 23:10 
QuestionCreating button in SL using createFromXaml() Pin
hxxbin23-Mar-09 11:48
hxxbin23-Mar-09 11:48 
AnswerRe: Creating button in SL using createFromXaml() Pin
Mark Salsbery23-Mar-09 17:50
Mark Salsbery23-Mar-09 17:50 
GeneralRe: Creating button in SL using createFromXaml() Pin
hxxbin26-Mar-09 17:55
hxxbin26-Mar-09 17:55 
QuestionListbox items - how to "owner draw" Pin
#realJSOP23-Mar-09 11:08
mve#realJSOP23-Mar-09 11:08 
AnswerRe: Listbox items - how to "owner draw" Pin
Christian Graus23-Mar-09 15:20
protectorChristian Graus23-Mar-09 15:20 
GeneralRe: Listbox items - how to "owner draw" Pin
#realJSOP23-Mar-09 23:21
mve#realJSOP23-Mar-09 23:21 
AnswerRe: Listbox items - how to "owner draw" Pin
ABitSmart23-Mar-09 17:28
ABitSmart23-Mar-09 17:28 
GeneralRe: Listbox items - how to "owner draw" Pin
#realJSOP23-Mar-09 23:20
mve#realJSOP23-Mar-09 23:20 
AnswerRe: Listbox items - how to "owner draw" Pin
Pete O'Hanlon24-Mar-09 1:30
mvePete O'Hanlon24-Mar-09 1:30 
GeneralRe: Listbox items - how to "owner draw" Pin
#realJSOP24-Mar-09 2:55
mve#realJSOP24-Mar-09 2:55 
GeneralRe: Listbox items - how to "owner draw" Pin
Pete O'Hanlon24-Mar-09 3:24
mvePete O'Hanlon24-Mar-09 3:24 
GeneralRe: Listbox items - how to "owner draw" Pin
#realJSOP24-Mar-09 3:56
mve#realJSOP24-Mar-09 3:56 
GeneralRe: Listbox items - how to "owner draw" Pin
Pete O'Hanlon24-Mar-09 5:37
mvePete O'Hanlon24-Mar-09 5:37 
GeneralRe: Listbox items - how to "owner draw" [modified] Pin
#realJSOP24-Mar-09 10:01
mve#realJSOP24-Mar-09 10:01 
GeneralRe: Listbox items - how to "owner draw" Pin
Pete O'Hanlon24-Mar-09 11:20
mvePete O'Hanlon24-Mar-09 11: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.