Hi,
I want to capture the events of controls placed inside the Outlookbar, which I cannot with the following code.
Please correct me if there is something going wrong in my code.
Thanks
Irfan
Xaml:
<Grid x:Name="LayoutRoot" Background="White"> <StackPanel Orientation="Horizontal" x:Name="StackPnl1"> <ig:XamOutlookBar HorizontalAlignment="Left" Height="400" Margin="10,10,0,0" Name="XamOutlookBar1" VerticalAlignment="Top" Width="200"> <ig:OutlookBarGroup Header="Sales" HorizontalAlignment="Stretch" Margin="0" Name="OutlookBarGroup1" VerticalAlignment="Stretch" > <ContentControl> <StackPanel> <Button Content="Button" Height="23" Name="Button1" Width="75" /> <HyperlinkButton Content="HyperlinkButton" Height="35" Name="HyperlinkButton1" Width="100" /> </StackPanel> </ContentControl> </ig:OutlookBarGroup> <ig:OutlookBarGroup Header="Stock" HorizontalAlignment="Stretch" Margin="0" Name="OutlookBarGroup2" VerticalAlignment="Stretch" > <ContentControl> </ContentControl> </ig:OutlookBarGroup> </ig:XamOutlookBar> <sdk:Label Height="28" Name="Label1" Width="120" /> </StackPanel> </Grid>
Xaml.vb:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click Label1.Content = "Clicked" End Sub Private Sub HyperlinkButton1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles HyperlinkButton1.Click Label1.Content = "Clicked" End Sub
Hello,
Please add the click event to the XAML as follows:
<StackPanel Orientation="Horizontal" x:Name="StackPnl1"> <ig:XamOutlookBar HorizontalAlignment="Left" Height="400" Margin="10,10,0,0" Name="XamOutlookBar1" VerticalAlignment="Top" Width="200"> <ig:OutlookBarGroup Header="Sales" HorizontalAlignment="Stretch" Margin="0" Name="OutlookBarGroup1" VerticalAlignment="Stretch" > <ContentControl> <StackPanel> <Button Content="Button" Height="23" Name="Button1" Width="75" Click="Button1_Click" /> <HyperlinkButton Content="HyperlinkButton" Height="35" Name="HyperlinkButton1" Width="100" Click="HyperlinkButton1_Click" /> </StackPanel> </ContentControl> </ig:OutlookBarGroup> <ig:OutlookBarGroup Header="Stock" HorizontalAlignment="Stretch" Margin="0" Name="OutlookBarGroup2" VerticalAlignment="Stretch" > <ContentControl> </ContentControl> </ig:OutlookBarGroup> </ig:XamOutlookBar> <sdk:Label Height="28" Name="Label1" Width="120" />
</StackPanel>
Let me know if you have any questions.
Valerie
Thanks for your time and effort. In my sample the code Click="Button1_Click" and Click="HyperlinkButton1_Click" has not been generated in the Xaml but in xaml.vb. Now its working fine after I write 'Click' event in Xaml.
Regards,
To fix that you just need to find the instance of the control from it's parent. Modify your click handler like so:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
Dim tvItem As XamTreeItem = New XamTreeItem
'Find the control from inside the parent. Dim xamTree1 = XamOutlookBar1.FindName("XamTree1") tvItem.Name = "itm1" tvItem.Header = "Item1" xamTree1.Items.Add(tvItem)
End Sub
I hope that helps, Best of luck,
Rich
Thanks a lot, that worked.
Modifying a little. by replacing the XamTree from OutlookBarGroup1 to OutlookBarGroup2 gives the same error. Can you please let me know how do I get the Instance of the control in this case.
Thank you,
<ig:XamOutlookBar HorizontalAlignment="Left" Height="400" Margin="10,10,0,0" Name="XamOutlookBar1" VerticalAlignment="Top" Width="200"> <ig:OutlookBarGroup Header="Sales" HorizontalAlignment="Stretch" Margin="0" Name="OutlookBarGroup1" VerticalAlignment="Stretch" > <ContentControl> <StackPanel> <Button Content="Button" Height="23" Name="Button2" Width="75" Click="Button2_Click" /> </StackPanel> </ContentControl> </ig:OutlookBarGroup> <ig:OutlookBarGroup Header="Stock" HorizontalAlignment="Stretch" Margin="0" Name="OutlookBarGroup2" VerticalAlignment="Stretch" > <ContentControl> <ig:XamTree Height="100" Name="XamTree1" Width="200" > </ig:XamTree> </ContentControl> </ig:OutlookBarGroup> </ig:XamOutlookBar>
This is a follow-up to see if you have any questions about capturing a click event.
Thank you,Sam
Sorry for the delayed response. It did work perfectly as expected.
Thank you very much,