इस कोड (ControlType = "ड्रॉपडाउन" तो पृष्ठभूमि पीला जब) काम करता है:मैं DataTrigger में टेक्स्टब्लॉक की दृश्यता को कैसे टॉगल कर सकता हूं?
<Window x:Class="TestCollapsed.Views.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:TestCollapsed.Commands"
Title="Main Window" Height="400" Width="800">
<Window.Resources>
<Style x:Key="DropDownStyle" TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding ControlType}" Value="dropDown">
<Setter Property="Background" Value="Yellow"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
<StackPanel>
<TextBlock Visibility="Visible"
Text="This is going to be the dropdown control."
Style="{StaticResource DropDownStyle}"/>
</StackPanel>
</Window>
लेकिन इस कोड है काम नहीं (ControlType = "ड्रॉपडाउन" तो TextBlock अभी भी है जब अदृश्य):
<Window x:Class="TestCollapsed.Views.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:TestCollapsed.Commands"
Title="Main Window" Height="400" Width="800">
<Window.Resources>
<Style x:Key="DropDownStyle" TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding ControlType}" Value="dropDown">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
<StackPanel>
<TextBlock Visibility="Collapsed"
Text="This is going to be the dropdown control."
Style="{StaticResource DropDownStyle}"/>
</StackPanel>
</Window>
क्यों मैं एक शैली में दृश्यता सेट नहीं कर सकता के रूप में मैं पृष्ठभूमि कर सकते हैं?
मैं था इससे पहले कि यह में डूब इस गलती को 10 बार बनाने के लिए –
हाँ, मुझे भी।। ट्रिगर्स के साथ कोड की समीक्षा करते समय अब पहली बात यह है कि मैं देखता हूं। –
जो वास्तव में मुद्दा था, धन्यवाद –