Saturday, October 6, 2012

Pass vb.net variable to XAML

Pass vb.net variable to XAML

I have found multiple ways of doing this but none seem to work in Silverlight 5. I have a varaible that I'm getting from click on a listbox item, then I drag it on to a treeview to build up the treeview. I am trying to make it so that when the item gets added to the treeview it creates a checkbox (which I've managed to do) however it never has any text it is just a checkbox. Here is my code:

<toolKit:ListBoxDragDropTarget AllowDrop="True" Name="ListBoxDragDropTarget1" AllowedSourceEffects="Link" Grid.Row="2" Grid.RowSpan="3">         <ListBox Grid.Row="0"  Height="375" HorizontalAlignment="Left" Margin="-1,15,0,0" Name="stoppageListBox" VerticalAlignment="Top" Width="203" />         </toolKit:ListBoxDragDropTarget>  <toolKit:TreeViewDragDropTarget AllowDrop="true" AllowedSourceEffects="All"  Name="TreeViewDragDropTarget1" Margin="6,0,0,0" Grid.Column="1" HorizontalAlignment="Left" Width="318" Height="353" VerticalAlignment="Top" Grid.Row="4">             <sdk:TreeView Grid.Column="1" Height="319" HorizontalAlignment="Left" Margin="5,12,0,0" Name="stoppageReasonsTreeView" VerticalAlignment="Top" Width="289">                 <sdk:TreeView.ItemTemplate>                     <DataTemplate>                     <StackPanel Orientation="Horizontal">                         <CheckBox IsChecked="{Binding IsShow}" Margin="0,0,2,0" />                             <sdk:Label Content="{Binding Path=selectedItem}" />                         </StackPanel>                     </DataTemplate>                 </sdk:TreeView.ItemTemplate>             </sdk:TreeView>         </toolKit:TreeViewDragDropTarget> 

In this bit of xaml it puts manages to put the treeview on as a checkbox just without any writing. TreeView without Text :S

All the vb.net code does behind it finds out what the item that was clicked on to is. So that is stored as a variable in the vb code. I want either a way of getting that variable so I can kill in the content for my checkbox, or automatically have the drag/drog create a textbox. Cheers Guys

Answers & Comments...




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog