Click here to Skip to main content
15,892,298 members
Home / Discussions / WPF
   

WPF

 
QuestionTreeView Control Item Styling Pin
Andy_L_J12-Aug-12 2:38
Andy_L_J12-Aug-12 2:38 
AnswerRe: TreeView Control Item Styling Pin
SledgeHammer0113-Aug-12 10:25
SledgeHammer0113-Aug-12 10:25 
GeneralGroupbox visibility problem in WPF after debugging and changing the combobox value Pin
karthik bandaru8-Aug-12 23:24
karthik bandaru8-Aug-12 23:24 
GeneralRe: Groupbox visibility problem in WPF after debugging and changing the combobox value Pin
Ed Hill _5_9-Aug-12 0:06
Ed Hill _5_9-Aug-12 0:06 
GeneralRe: Groupbox visibility problem in WPF after debugging and changing the combobox value Pin
karthik bandaru9-Aug-12 0:23
karthik bandaru9-Aug-12 0:23 
GeneralRe: Groupbox visibility problem in WPF after debugging and changing the combobox value Pin
Ed Hill _5_9-Aug-12 0:31
Ed Hill _5_9-Aug-12 0:31 
GeneralRe: Groupbox visibility problem in WPF after debugging and changing the combobox value Pin
karthik bandaru9-Aug-12 0:42
karthik bandaru9-Aug-12 0:42 
GeneralRe: Groupbox visibility problem in WPF after debugging and changing the combobox value Pin
Ed Hill _5_9-Aug-12 0:56
Ed Hill _5_9-Aug-12 0:56 
I have provided you with a sample using the code behind, but i would say that it is worth getting used to all the things that you can do with WPF in the xaml files. As with any programming there are so many ways to do things, the styles i was suggesting can be created as resources and be reused easily by the group boxes. If you are using the MVVM approach what you may be looking to do is use templates to get your UI to change depending on Properties in the ViewModel. Just as a quick untested example if you are worried about having too much xmal, this is just a different appraoch.

It is worth noting that the resources can be placed in different places, and the are in scope in any elements below where they are created, also they can be kept out of the way in resource dictionarys. Hopefully one of these solutions will work for you even if it is the code behind one.
XML
<StackPanel>
    <StackPanel.Resources>
        <Style TargetType="GroupBox" x:Key="OneAndThree">
            <Setter Property="Visibility" Value="Collapsed"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding ElementName=Options, Path=SelectedItem}" Value="One">
                    <Setter Property="Visibility" Value="Visible"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding ElementName=Options, Path=SelectedItem}" Value="Three">
                    <Setter Property="Visibility" Value="Visible"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
        <Style TargetType="GroupBox" x:Key="Two">
            <Setter Property="Visibility" Value="Collapsed"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding ElementName=Options, Path=SelectedItem}" Value="Two">
                    <Setter Property="Visibility" Value="Visible"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </StackPanel.Resources>
    <ComboBox Name="Options">
        <sys:String>One</sys:String>
        <sys:String>Two</sys:String>
        <sys:String>Three</sys:String>
    </ComboBox>
    <GroupBox Name="group1" Header="OneOrThree" Style="{StaticResource OneAndThree}">
    </GroupBox>
    <GroupBox Name="group2" Header="Two" Style="{StaticResource Two}">
        <!--<GroupBox.Style>
            
        </GroupBox.Style>-->
    </GroupBox>
</StackPanel>

GeneralRe: Groupbox visibility problem in WPF after debugging and changing the combobox value Pin
Ed Hill _5_9-Aug-12 0:47
Ed Hill _5_9-Aug-12 0:47 
GeneralRe: Groupbox visibility problem in WPF after debugging and changing the combobox value Pin
karthik bandaru9-Aug-12 0:50
karthik bandaru9-Aug-12 0:50 
GeneralRe: Groupbox visibility problem in WPF after debugging and changing the combobox value Pin
karthik bandaru9-Aug-12 2:10
karthik bandaru9-Aug-12 2:10 
GeneralRe: Groupbox visibility problem in WPF after debugging and changing the combobox value Pin
Ed Hill _5_9-Aug-12 2:24
Ed Hill _5_9-Aug-12 2:24 
SuggestionRegarding MVVM framework for WPF Pin
Member 92251325-Aug-12 3:55
Member 92251325-Aug-12 3:55 
GeneralRe: Regarding MVVM framework for WPF Pin
Richard MacCutchan5-Aug-12 6:55
mveRichard MacCutchan5-Aug-12 6:55 
GeneralWPF Update UI When Collection Changes Pin
Kevin Marois1-Aug-12 11:05
professionalKevin Marois1-Aug-12 11:05 
GeneralRe: WPF Update UI When Collection Changes Pin
Pete O'Hanlon1-Aug-12 11:44
mvePete O'Hanlon1-Aug-12 11:44 
GeneralRe: WPF Update UI When Collection Changes Pin
Kevin Marois1-Aug-12 11:52
professionalKevin Marois1-Aug-12 11:52 
GeneralRe: WPF Update UI When Collection Changes Pin
Pete O'Hanlon1-Aug-12 12:10
mvePete O'Hanlon1-Aug-12 12:10 
GeneralRe: WPF Update UI When Collection Changes Pin
Kevin Marois1-Aug-12 12:23
professionalKevin Marois1-Aug-12 12:23 
GeneralRe: WPF Update UI When Collection Changes Pin
Pete O'Hanlon1-Aug-12 12:45
mvePete O'Hanlon1-Aug-12 12:45 
GeneralRe: WPF Update UI When Collection Changes Pin
Kevin Marois1-Aug-12 12:51
professionalKevin Marois1-Aug-12 12:51 
GeneralRe: WPF Update UI When Collection Changes Pin
Mycroft Holmes1-Aug-12 13:10
professionalMycroft Holmes1-Aug-12 13:10 
GeneralRe: WPF Update UI When Collection Changes Pin
Kevin Marois1-Aug-12 13:27
professionalKevin Marois1-Aug-12 13:27 
GeneralRe: WPF Update UI When Collection Changes Pin
Kevin Marois6-Aug-12 7:25
professionalKevin Marois6-Aug-12 7:25 
GeneralRe: WPF Update UI When Collection Changes Pin
Mycroft Holmes6-Aug-12 12:38
professionalMycroft Holmes6-Aug-12 12:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.