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
Sorry for the delayed response. It did work perfectly as expected.
Thank you very much,
This is a follow-up to see if you have any questions about capturing a click event.
Thank you,Sam
Basically you have a collection of Groups in the Outlookbar. You need to give each Group a key so then you can later find that group. Once you've found the group, you can grab the control you looking for.
1.) You need to extend you Xaml to include Keys for each group:
<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" Key="ouGroup1" 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" Key="ouGroup2" VerticalAlignment="Stretch" > <ContentControl> <ig:XamTree Height="100" Name="XamTree1" Width="200" >
</ig:XamTree> </ContentControl> </ig:OutlookBarGroup> </ig:XamOutlookBar>
2.) Then in the code behind, grab the proper group, and then look for your Tree:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
Dim tvItem As XamTreeItem = New XamTreeItem
'We can use the key from the Xaml to get our group Dim ouBar2 = XamOutlookBar1.Groups("ouGroup2")
If (ouBar2 Is Nothing) Then Return End If
'Now we can check that instance of the group to find our control Dim xamTree1 = ouBar2.FindName("XamTree1")
If (xamTree1 Is Nothing) Then Return End If
tvItem.Name = "itm1" tvItem.Header = "Item1" xamTree1.Items.Add(tvItem)
End Sub
Hope that helps,Thanks,Rich
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>
Thanks a lot, that worked.
Regards,