Hi,
I'm new to C# and Silverlight, so I might just be on the completely wrong way:
The Treeview itself:
When opening a window to get some detailed informations on some items I'm restricted on passing the value of the UI Elements, in this case I'm passing the first Textbox (RuleAttributeInput).
In order to have access to the TreeViewElement (and furthermore its attributes) the user is working in, I want to pass the TreeViewElement to the Window, but I'm not able to get it right. When using parent I get to the top tier stackpanel but always end up with a null element.
Of course I could force users to first select the treeviewelement to get me the selectedItem, but maybe theres a way without needing to select any TreeviewElements (and just click on the Button).
Any idea on how to identify a TreeviewElement when having only an embedded UIElement as Sender?
I'm new to C# and Silverlight, so I might just be on the completely wrong way:
I have a set of TreeViews of this kind:
<
telerikCore:HierarchicalDataTemplate
x:Name
=
"MainTemplate"
ItemsSource
=
"{Binding Children, Mode=TwoWay}"
telerikCore:ContainerBinding.ContainerBindings
=
"{StaticResource BindingsCollection}"
>
<
StackPanel
Orientation
=
"Horizontal"
Background
=
"Transparent"
>
<!--Rules-->
<
StackPanel
x:Name
=
"ListPanel"
Margin
=
"30,3,30,3"
Orientation
=
"Horizontal"
Visibility
=
"{Binding IsRuleVisible, Converter={StaticResource VisibleConverter}}"
HorizontalAlignment
=
"Center"
VerticalAlignment
=
"Center"
>
<
TextBox
x:Name
=
"RuleAttributeInput"
Text
=
"{Binding RuleAttribute, Mode=TwoWay}"
Width
=
"200"
MaxWidth
=
"200"
IsEnabled
=
"False"
></
TextBox
>
<
Button
Content
=
"V"
x:Name
=
"MetaDataWindow"
Click
=
"MetaDataWindow_Click"
></
Button
>
<
ComboBox
x:Name
=
"OperatorComboBox"
Width
=
"100"
Margin
=
"5 0 0 0"
ItemsSource
=
"{Binding NumOpList}"
SelectedValue
=
"{Binding RuleOperator, Mode=TwoWay}"
Loaded
=
"OperatorComboBox_Loaded"
/>
<
telerikInput:RadMaskedTextBox
x:Name
=
"RuleValueInput"
Width
=
"100"
Margin
=
"5 0 0 0"
FontSize
=
"10"
MaskType
=
"None"
Value
=
"{Binding RuleValue, Mode=TwoWay}"
/>
</
StackPanel
>
<!--Operators-->
<
StackPanel
Orientation
=
"Horizontal"
HorizontalAlignment
=
"Center"
Visibility
=
"{Binding IsOperatorVisible, Converter={StaticResource VisibleConverter}}"
>
<
TextBlock
Text
=
"{Binding LogOperator, Mode=TwoWay, Converter={StaticResource LogOpConverter}}"
Width
=
"40"
Margin
=
"10"
TextAlignment
=
"Center"
></
TextBlock
>
</
StackPanel
>
</
StackPanel
>
</
telerikCore:HierarchicalDataTemplate
>
<
telerik:RadTreeView
x:Name
=
"RuleTreeView"
SelectionMode
=
"Multiple"
ItemContainerStyle
=
"{StaticResource TreeViewItemStyle}"
ItemTemplate
=
"{StaticResource MainTemplate}"
IsExpandOnSingleClickEnabled
=
"False"
DragStarted
=
"RadTreeView_DragStarted"
HorizontalAlignment
=
"Left"
HorizontalContentAlignment
=
"Left"
IsDragDropEnabled
=
"True"
IsEditable
=
"True"
IsSingleExpandPath
=
"False"
IsExpandOnDblClickEnabled
=
"False"
>
</
telerik:RadTreeView
>
When opening a window to get some detailed informations on some items I'm restricted on passing the value of the UI Elements, in this case I'm passing the first Textbox (RuleAttributeInput).
private
void
MetaDataWindow_Click(
object
sender, RoutedEventArgs e)
{
MyWindow newWindow =
new
MyWindow(((System.Windows.Controls.Panel)((System.Windows.FrameworkElement)sender).Parent).Children[0]);
newWindow.Show();
}
In order to have access to the TreeViewElement (and furthermore its attributes) the user is working in, I want to pass the TreeViewElement to the Window, but I'm not able to get it right. When using parent I get to the top tier stackpanel but always end up with a null element.
Of course I could force users to first select the treeviewelement to get me the selectedItem, but maybe theres a way without needing to select any TreeviewElements (and just click on the Button).
Any idea on how to identify a TreeviewElement when having only an embedded UIElement as Sender?