Hi,
I have created a silverlight page with xamoutlookbar which has the hierarchy like the following
xamoutlookbar group1 datetime1Control datetime2Control group2 CheckBox1Control CheckBox2Control RadioButton1Control group3 Calendar1Control
But whenever I try to get the value of these controls, I am getting null reference exception.For eg:-
I tried both the following codes
DateTime dTime = datetime1Control.SelectedDate.Value;DatePicker dPicker1 = this.FindName("datetime1Control") as DatePicker;
Please help
Thanks-Sajin
This is known limitation in Silverlight, this post should give you more information.
HTH,
Thanks for your reply.
But using that approach I get the first control, but I want something like 3rd control from the group.
Thanks
-Sajin
I think that maybe you could try the following hacky solution, note that for all elements for which you defined Name/x:Name properties in XAML, a field is automatically defined in the corresponding .xaml.g.cs file (you can open it by choosing project 'see all files' option and going to the obj directory):
<Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ig:XamOutlookBar x:Name="OutlookBar1" HorizontalAlignment="Left">
<ig:OutlookBarGroup>
<Grid x:Name="Grid1">
<ig:XamTree x:Name="Tree1">
<ig:XamTreeItem x:Name="TreeItem1" Header="Level1Node1"/>
<ig:XamTreeItem Header="Level1Node2"/>
</ig:XamTree>
<Ellipse x:Name="Ellipse1" Grid.Row="1" Height="200" Width="100" Fill="Red"/>
</Grid>
</ig:OutlookBarGroup>
</ig:XamOutlookBar>
<Button Grid.Row="1" Content="Stretch Ellipse" Click="Button_Click" Margin="10"/>
public partial class OutlookBar : UserControl
{
public OutlookBar()
InitializeComponent();
this.OutlookBar1.LayoutUpdated += this.OutlookBar1_LayoutUpdated;
}
void OutlookBar1_LayoutUpdated(object sender, EventArgs e)
this.Tree1 = ((XamTree)(this.FindName("Tree1")));
this.TreeItem1 = ((XamTreeItem)(this.FindName("TreeItem1")));
this.Ellipse1 = ((Ellipse)(this.FindName("Ellipse1")));
this.OutlookBar1.LayoutUpdated -= this.OutlookBar1_LayoutUpdated;
private void Button_Click(object sender, RoutedEventArgs e)
this.Ellipse1.Width = 200;
Thank you so much. That worked!!!!!!!!!!!!