How do I bind ListItem to CommandParameter - c#

I have a ListBox :
<ListBox Margin="10" Padding="10" ItemsSource="{Binding Items}">
<ListBox.ItemTemplate>
<DataTemplate>
<!-- Data template -->
<Grid>
<Grid.ColumnDefinitions>
<!--Image-->
<ColumnDefinition Width="auto" />
<!--Info-->
<ColumnDefinition Width="500" />
<!--Options-->
<ColumnDefinition Width="*" /
</Grid.ColumnDefinitions>
<Image Height="50" Width="50" />
<StackPanel Grid.Column="1" HorizontalAlignment="Left">
<StackPanel Orientation="Horizontal">
<TextBlock Text="Name: " />
<TextBlock Text="{Binding Name}" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="ID: " />
<TextBlock Text="{Binding ID}" />
</StackPanel>
</StackPanel>
<Button Grid.Column="2" Content="{Binding Status}" Command="{Binding CompleteCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainPageViewModel}}}" CommandParameter="{Binding}" HorizontalAlignment="Right" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I need my CommandParameter be the ListItem of this ListBox.

Set the AncestorType to ListBox and include DataContext in the path:
<Button ... Command="{Binding DataContext.CompleteCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBox}}}" CommandParameter="{Binding}" HorizontalAlignment="Right"></Button>
Then the Command binding should work provided that the CompleteCommand property belongs to the same class as the Items property

Related

How to disable listbox item underlined when ALT key is pressed in wpf

I have a Listbox with some string and int items. When ALT key is pressed the list items are unlined. I have set in ContentPresenter style like this, RecognizesAccessKey="False". But it is not working. Please anyone suggest me to fix this. The Listbox values are like this, T1_1.
MainWindow
<ListBox
x:Name="dropListBox"
Grid.Row="1"
Margin="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
AllowDrop="True"
Background="#F8F8F8"
BorderThickness="0"
ItemContainerStyle="{StaticResource ListBoxItemStyle}"
ItemsSource="{Binding DetailsCollection}"
Style="{StaticResource ListBoxStyle}">
<ListBox.ItemTemplate>
<DataTemplate>
<ItemsControl ItemsSource="{Binding Values}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image
Grid.Column="0"
Width="23"
Height="23"
Source="{Binding State, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource IntToImageSourceConverter}}" />
<Label
Grid.Column="1"
Content="{Binding Name}"
FontSize="12" />
<Label
Grid.Column="2"
HorizontalAlignment="Right"
HorizontalContentAlignment="Right"
Content="{Binding CurrentValue}"
FontSize="12" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

(C#) Popup of grid appear on buttons tap

I have this xaml code on one of the windows in my app:
<phone:PanoramaItem x:Name="panoramaItemSend" Header="{Binding LocalizedResources.send, Source={StaticResource LocalizedStrings}}" >
<StackPanel Margin="12,0,0,0">
<TextBlock Text="{Binding LocalizedResources.recipientEmail, Source={StaticResource LocalizedStrings}}" />
<TextBox InputScope="EmailUserName" Text="{Binding SendModel.Email, Mode=TwoWay}" Margin="-12,0,0,0" TabIndex="100" GotFocus="TextBox_GotFocus" LostFocus="TextBox_LostFocus" MaxLength="256" Height="105" TextWrapping="Wrap">
<i:Interaction.Behaviors>
<prismInteractivity:UpdateTextBindingOnPropertyChanged/>
</i:Interaction.Behaviors>
</TextBox>
<TextBlock Text="{Binding LocalizedResources.amount, Source={StaticResource LocalizedStrings}}" />
<TextBox x:Name="txtSendAmount" InputScope="Number" Text="{Binding SendModel.Amount, Mode=TwoWay}" Margin="-12,0,0,0" GotFocus="TextBox_GotFocus" LostFocus="TextBox_LostFocus" TabIndex="101" MaxLength="20" TextChanged="TextBox_TextChanged" >
<i:Interaction.Behaviors>
<prismInteractivity:UpdateTextBindingOnPropertyChanged/>
</i:Interaction.Behaviors>
</TextBox>
<TextBlock Text="{Binding SendModel.AmountFiatStr}" Margin="0,-15,0,5" Foreground="Gainsboro"/>
<TextBlock Text="{Binding LocalizedResources.label, Source={StaticResource LocalizedStrings}}" />
<TextBox Text="{Binding SendModel.Label, Mode=TwoWay}" Margin="-12,0,0,0" TabIndex="102" GotFocus="TextBox_GotFocus" LostFocus="TextBox_LostFocus" MaxLength="256">
<i:Interaction.Behaviors>
<prismInteractivity:UpdateTextBindingOnPropertyChanged/>
</i:Interaction.Behaviors>
</TextBox>
<TextBlock Text="{Binding LocalizedResources.message, Source={StaticResource LocalizedStrings}}" />
<TextBox Text="{Binding SendModel.Message, Mode=TwoWay}" Margin="-12,0,0,0" TabIndex="103" GotFocus="TextBox_GotFocus" LostFocus="TextBox_LostFocus" MaxLength="256">
<i:Interaction.Behaviors>
<prismInteractivity:UpdateTextBindingOnPropertyChanged/>
</i:Interaction.Behaviors>
</TextBox>
<Button x:Name="btnSend" Content="{Binding LocalizedResources.send, Source={StaticResource LocalizedStrings}}" Style="{StaticResource OrangeButton}" Tap="btnSend_Tap" TabIndex="104"/>
</StackPanel>
I want to create a popup when I trigger btnSend's Tap handler - btnSendTap
My popup should have this grid full of accounts that I already know how to add programatically:
<Grid Margin="15,0,0,21">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel x:Name="AccountsInfo" Grid.Row="0">
</StackPanel>
<StackPanel Grid.Row="1">
<local:RateChart x:Name="rateChart" Height="324" Margin="-12,25,0,0" Width="417" />
</StackPanel>
</Grid>
Have a look at the PopUp control.
Hope that is what you are looking for. :)

Bind all Tab item view model at start in WPF

I have an application with 2 tabs which are Person and User Management in WPF with MVVM. Now the problem is when I click on Person Mag tab, the PersonViewModel will bind to Person Mag View, and User Mag same as mentioned situation also.
How to make Person and User Mag tab bind its view model at start of the application (both bind viewmodel for its own view at the same time) instead of bind the view model when I clicked on that tab.
XAML
<DockPanel LastChildFill="True">
<TabControl TabStripPlacement="Left" DockPanel.Dock="Left" Margin="5">
<TabItem Width="190" Margin="1">
<TabItem.Header>
<StackPanel Orientation="Horizontal">
<Image Source="/Images/Person-Management-Icon.png" Width="32" Height="32" />
<TextBlock Text="Person Mangement" Margin="5,0,0,0" VerticalAlignment="Center" />
</StackPanel>
</TabItem.Header>
<TabItem.ContentTemplate>
<DataTemplate>
<ptab:PersonManagementView />
</DataTemplate>
</TabItem.ContentTemplate>
</TabItem>
<TabItem Margin="1">
<TabItem.Header>
<StackPanel Orientation="Horizontal">
<Image Source="/Images/User-Management-Icon.png" Width="32" Height="32" />
<TextBlock Text="User Mangement" Margin="5,0,0,0" VerticalAlignment="Center" />
</StackPanel>
</TabItem.Header>
<TabItem.ContentTemplate>
<DataTemplate>
<ptab:UserManagementView />
</DataTemplate>
</TabItem.ContentTemplate>
</TabItem>
</TabControl>
</DockPanel>
PersonManagement XAML
<!--View Model Section-->
<UserControl.DataContext>
<vm:PersonViewModel />
</UserControl.DataContext>
<!--End View Model Section-->
<!--Resources Section-->
<UserControl.Resources>
<ResourceDictionary Source="../Resources/ResourceDictionary.xaml" />
</UserControl.Resources>
<!--End Resources Section-->
<DockPanel Name="Person_Management_View">
<TabControl DockPanel.Dock="Top">
<TabItem>
<TabItem.Header>
<StackPanel Orientation="Horizontal">
<Image Source="/Images/Person-Creation-Icon.png" Width="24" Height="24" />
<TextBlock Text="Person Creation" Margin="5,0,0,0" VerticalAlignment="Center" />
</StackPanel>
</TabItem.Header>
<Grid>
<Grid.RowDefinitions>
<!--Name-->
<RowDefinition Height="Auto" />
<!--Gender-->
<RowDefinition Height="Auto" />
<!--Department-->
<RowDefinition Height="Auto" />
<!--Error Message-->
<RowDefinition Height="25" />
<!--Save Button-->
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="50" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!--Name Section-->
<Label Grid.Row="0" Grid.Column="0" Content="Name"/>
<Label Grid.Row="0" Grid.Column="1" Content=":"/>
<TextBox Name="txtPersonName" Grid.Row="0" Grid.Column="2" Margin="4">
<TextBox.Text>
<Binding Path="PersonObject.Name" UpdateSourceTrigger="PropertyChanged" >
<Binding.ValidationRules>
<r:PersonNameRule ValidatesOnTargetUpdated="True" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<!--End Name Section-->
<!--Gender Section-->
<Label Grid.Row="1" Grid.Column="0" Content="Gender"/>
<Label Grid.Row="1" Grid.Column="1" Content=":"/>
<ComboBox Grid.Row="1" Grid.Column="2" Margin="4" ItemsSource="{Binding GenderList}" SelectedItem="{Binding PersonObject.Gender}"/>
<!--End Gender Section-->
<!--Department Section-->
<Label Grid.Row="2" Grid.Column="0" Content="Department" />
<Label Grid.Row="2" Grid.Column="1" Content=":"/>
<ComboBox Grid.Row="2" Grid.Column="2" Margin="4" ItemsSource="{Binding DepartmentList}" SelectedItem="{Binding PersonObject.DepartmentName}" />
<!--End Department Section-->
<!--Error Message Section-->
<TextBlock Grid.Row="3" Grid.Column="2" Margin="4,4,4,0" Visibility="{Binding ElementName=txtPersonName, Path=(Validation.Errors), Converter={StaticResource toVisibilityConverter}}" Style="{StaticResource RedTextBlock}">
<TextBlock.Text>
<Binding ElementName="txtPersonName" Path="(Validation.Errors).CurrentItem.ErrorContent"/>
</TextBlock.Text>
</TextBlock>
<!--End Error Message Section-->
<!--Save Button Section-->
<Button Grid.Row="4" Grid.Column="2" HorizontalAlignment="Right" MinWidth="100" Margin="4,0,4,4" Content="Save" Command="{Binding CreatePersonCommand}">
<Button.Style>
<Style TargetType="{x:Type Button}">
<Setter Property="IsEnabled" Value="false" />
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ElementName=txtPersonName, Path=(Validation.HasError)}" Value="false" />
</MultiDataTrigger.Conditions>
<Setter Property="IsEnabled" Value="true" />
</MultiDataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<!--End Save Button Section-->
</Grid>
</TabItem>
</TabControl>
<!--Person Data Section-->
<DataGrid Name="PersonDataGrid" DockPanel.Dock="Bottom" AutoGenerateColumns="False" IsReadOnly="True" SelectionMode="Single" ColumnWidth="*" ItemsSource="{Binding PersonList}">
<DataGrid.Columns>
<DataGridTextColumn Header="Id" Binding="{Binding PersonID}" />
<DataGridTextColumn Header="Name" Binding="{Binding Name}" />
<DataGridTextColumn Header="Gender" Binding="{Binding Gender, Converter={StaticResource emptyStringConverter}}" />
<DataGridTextColumn Header="Department" Binding="{Binding DepartmentName, Converter={StaticResource emptyStringConverter}}" />
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button IsEnabled="{Binding Selected, Converter={StaticResource oppositeBoolConverter}}" Command="{Binding DataContext.DeletePersonCommand, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" CommandParameter="{Binding PersonID}" Style="{StaticResource TransparentButton}">
<Image Source="{Binding Selected, Converter={StaticResource deleteImageConverter}}" Width="16" Height="16"/>
</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Command="{Binding DataContext.ViewPersonCommand, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" CommandParameter="{Binding PersonID}" Style="{StaticResource TransparentButton}">
<Image Source="/Images/Update-Icon.png" Width="16" Height="16"/>
</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<!--End Person Data Section-->
</DockPanel>
Try this
Add Loaded event to TabControl
<TabControl TabStripPlacement="Left" DockPanel.Dock="Left" Margin="5" Loaded="Tab_OnLoaded" >
Remove the ContentTemplate from xaml and assign content in code like
void Tab_OnLoaded(object sender, RoutedEventArgs e)
{
var tabControl = sender as TabControl;
if (tabControl != null)
{
for (int i = 0; i < tabControl.Items.Count; i++)
{
if (i == 1)
(tabControl.Items[i] as TabItem).Content = new UserControl2();//Here assign the Usercontrol that you want to set as Content
}
tabControl.Loaded -= Tab_OnLoaded; // Do this on first time only
}
}
I dont think its a good approach . I hope this will help.

WPF Show buttons inside a selected ListItem

I'm working with a WPF application to manage our main software's versions. This application has a ListBox, and I set the ListBox.DataTemplate to each ListBoxItem has a Label and 2 Buttons inside it.
The following code shows my ListBox code:
<ListBox Grid.Row="0" SelectedItem="{Binding Path=SelectedVersion}" ItemsSource="{Binding Path=PatchList, Mode=TwoWay}" d:DataContext="{d:DesignInstance {x:Type ViewModels:MainWindowViewModel}}"
SelectionMode="Single" IsSynchronizedWithCurrentItem="True" Margin="1" ScrollViewer.HorizontalScrollBarVisibility="Disabled" SelectedIndex="0">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Content="{Binding Path=VersionNumber}" HorizontalAlignment="Left" Foreground="#FFFFFF" FontSize="19" />
<Button Grid.Column="1" Width="25" Height="25" Template="{StaticResource OnMouseOverListBoxitem}" ToolTip="Release" Command="{Binding Path=DataContext.ReleaseVersionCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBox}}}" HorizontalAlignment="Right" d:DataContext="{d:DesignInstance {x:Type ViewModels:MainWindowViewModel}}" CommandParameter="{Binding}">
<ContentControl Template="{StaticResource Release}" />
</Button>
<Button Grid.Column="2" Width="25" Height="25" Template="{StaticResource OnMouseOverListBoxitem}" ToolTip="Trash" Command="{Binding Path=DataContext.DeleteVersionCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBox}}}" HorizontalAlignment="Right" d:DataContext="{d:DesignInstance {x:Type ViewModels:MainWindowViewModel}}" CommandParameter="{Binding}">
<ContentControl Template="{StaticResource Trash}" />
</Button>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
The problem is that I would like to show the label and the buttons ONLY for the Selected ListBoxItem.
By the way, I'm using bindings, and if you see some different code it's because I'm also using MahApp.Metro for Windows8-style.
Any suggestions?
Thank you.
try this one.
<Window.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter1" />
</Window.Resources>
<Grid>
<ListBox ItemsSource="{Binding Fnts}" Grid.Row="0" SelectedItem="{Binding Path=SelectedVersion}"
SelectionMode="Single" IsSynchronizedWithCurrentItem="True" Margin="1" ScrollViewer.HorizontalScrollBarVisibility="Disabled" SelectedIndex="0">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Label Content="{Binding}" />
<Button Content=" X " Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}, Path=IsSelected, Converter={StaticResource BooleanToVisibilityConverter1}}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>

Silverlight treeview with multiple TreeViewItemStyle

Depending on bound item - I use different data templates to display data. Now I also need to modify behavior/style of treeview itself. Is it possible to switch style for items depending on object property? Right now it's only one specified: ItemContainerStyle="{StaticResource TreeViewItemStyleFolder}"
I would like to create second style TreeViewItemStyleDocument
Current XAML (with custom style and template selector)
<sdk:TreeView ItemsSource="{Binding Items}"
Grid.Row="1"
Style="{StaticResource TreeViewStyle1}"
ItemContainerStyle="{StaticResource TreeViewItemStyleFolder}"
>
<sdk:TreeView.ItemTemplate>
<sdk:HierarchicalDataTemplate ItemsSource="{Binding SubItems}">
<DocumentManagement:DocumentTreeViewItemTemplateSelector
Content="{Binding}">
<DocumentManagement:DocumentTreeViewItemTemplateSelector.FolderTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="24" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- FOLDER ICON AND CAPTION -->
<Image Source="{Binding IconSource}" Width="24" Height="24" />
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Left"
Grid.Column="1" Margin="5,0"
Text="{Binding Folder.FolderId}" FontSize="12" Foreground="#2C2C2C" />
</Grid>
</DataTemplate>
</DocumentManagement:DocumentTreeViewItemTemplateSelector.FolderTemplate>
<DocumentManagement:DocumentTreeViewItemTemplateSelector.DocumentTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="24" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="1" Orientation="Horizontal">
<TextBlock FontSize="10" Foreground="#2C2C2C">
<Run Text="Added by" />
<Run Text="{Binding Document.MEMUser.UserName}" />
<Run Text=" on " />
<Run Text="{Binding CreatedOn, Converter={StaticResource DateTimeToStringConverter}}" />
</TextBlock>
<!--BIND COMMANDS TO PARENT ViewModel to process operations-->
<Button Content="Delete" Command="{Binding DataContext.DeleteCommand, ElementName=LayoutRoot}" CommandParameter="{Binding}" />
<Button Content="Download" Command="{Binding DataContext.DownloadCommand, ElementName=LayoutRoot}" CommandParameter="{Binding}" />
</StackPanel>
</Grid>
</DataTemplate>
</DocumentManagement:DocumentTreeViewItemTemplateSelector.DocumentTemplate>
</DocumentManagement:DocumentTreeViewItemTemplateSelector>
</sdk:HierarchicalDataTemplate>
</sdk:TreeView.ItemTemplate>
</sdk:TreeView>
EDIT:
Added triggers to switch ItemContainerStyle based on property but I think problem is that I'm using hieratchical data template. If I put breakpoint on IsFolder property - there is no source object.
<sdk:TreeView x:Name="DocumentsTreeView" ItemsSource="{Binding Items}"
Grid.Row="1"
Style="{StaticResource TreeViewStyleTransparent}">
<!-- ItemContainerStyle="{StaticResource TreeViewItemStyleFolders}"-->
<i:Interaction.Triggers>
<ei:DataTrigger Value="False" Binding="{Binding IsFolder}">
<ei:ChangePropertyAction TargetName="DocumentTreeView" PropertyName="ItemContainerStyle"
Value="{StaticResource TreeViewItemStyleFolders}" />
</ei:DataTrigger>
<ei:DataTrigger Value="True" Binding="{Binding IsFolder}">
<ei:ChangePropertyAction TargetName="DocumentTreeView" PropertyName="ItemContainerStyle"
Value="{StaticResource TreeViewItemStyleDocuments}" />
</ei:DataTrigger>
</i:Interaction.Triggers>
<sdk:TreeView.ItemTemplate>
<sdk:HierarchicalDataTemplate ItemsSource="{Binding SubItems}">
<DocumentManagement:DocumentTreeViewItemTemplateSelector
Content="{Binding}">
<DocumentManagement:DocumentTreeViewItemTemplateSelector.FolderTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="24" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- FOLDER ICON AND CAPTION -->
<Image Source="{Binding IconSource}" Width="24" Height="24" />
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Left"
Grid.Column="1" Margin="5,0"
Text="{Binding Folder.FolderId}" FontSize="12" Foreground="#2C2C2C" />
</Grid>
</DataTemplate>
</DocumentManagement:DocumentTreeViewItemTemplateSelector.FolderTemplate>
<DocumentManagement:DocumentTreeViewItemTemplateSelector.DocumentTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="24" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="1" Orientation="Horizontal">
<TextBlock FontSize="10" Foreground="#2C2C2C">
<Run Text="Added by" />
<Run Text="{Binding Document.MEMUser.UserName}" />
<Run Text="on" />
<Run Text="{Binding Document.CreatedOn, Converter={StaticResource DateTimeToStringConverter}}" />
</TextBlock>
<!--BIND COMMANDS TO PARENT ViewModel to process operations-->
<Button Content="Delete" Command="{Binding DataContext.DeleteCommand, ElementName=LayoutRoot}" CommandParameter="{Binding}" />
<Button Content="Download" Command="{Binding DataContext.DownloadCommand, ElementName=LayoutRoot}" CommandParameter="{Binding}" />
</StackPanel>
</Grid>
</DataTemplate>
</DocumentManagement:DocumentTreeViewItemTemplateSelector.DocumentTemplate>
</DocumentManagement:DocumentTreeViewItemTemplateSelector>
</sdk:HierarchicalDataTemplate>
</sdk:TreeView.ItemTemplate>
</sdk:TreeView>
If I understand correctly you want style to change dynamically based on a property value and you want this to be performed globally on everyitems on the page referencing the given style?
If that is the case I would suggest you looking into storyboards and states within Expression Blend. I do not see you mentioning Blend in your description. Are you using it? The treeview has many items that can be customized and some that are harder. I had an issue last week that my hyperlinks that were nested within a treeview could not effectively change the font color. I would probably been able to do it spending more time on the design but I changed the design intent instead.
The preview version of Blend for Silverlight 5 is free until June 2013 according to my install.
http://www.microsoft.com/en-us/download/details.aspx?id=9503
Good luck,

Categories