TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
zohaib khan
NA
26
37.1k
WPF XMAL trigger from button to change combo box item color.
Jul 11 2012 9:10 AM
Hi,
I have combo box and button in my project(WPF application)
In following example I have change color of button when "ButtonName" press and other example I have change color of "Item3 and Item4" when selected.
Any idea how to change Background color of "Item3 and Item4" in combo box when "ButtonName" is press.?
[1]. Example1
<Button Width="73" Height="23" Content="ButtonName" Grid.Row="1" Grid.Column="1" Margin="104,202,180,45">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="button3" CornerRadius="2" BorderThickness="1">
<ContentPresenter Margin="4" VerticalAlignment="Top" HorizontalAlignment="Right"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="button3" Property="Background" Value="Pink"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
[2]. Example2
<ComboBox TabIndex="1" x:Name="txtTitle" Margin="253,40,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" Height="23" SelectionChanged="txtTitle_SelectionChanged" Grid.ColumnSpan="2">
<ComboBoxItem Content="Item1" />
<ComboBoxItem Content="Item2" />
<ComboBoxItem Content="Item3" />
<ComboBoxItem Content="Item4" />
<ComboBoxItem Content="Item5" />
<ComboBox.Style>
<Style TargetType="ComboBox">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=SelectedItem.Content, ElementName=txtTitle}" Value="Item3">
<Setter Property="Background" Value="Pink"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=SelectedItem.Content, ElementName=txtTitle}" Value="Item4">
<Setter Property="Background" Value="Yellow"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ComboBox.Style>
</ComboBox>
- Thanks
Zohaib.
Reply
Answers (
2
)
What is XPath in Xml?
how animation (Story Board) done with xaml coding Like Working Functionalities of Talking tom In Anriod Feature....