44using System . Windows ;
55using System . Windows . Controls ;
66using System . Windows . Data ;
7+ using System . Windows . Media ;
78using Page = iNKORE . UI . WPF . Modern . Controls . Page ;
89
910namespace iNKORE . UI . WPF . Modern . Gallery . Pages . Controls . Windows
@@ -18,62 +19,35 @@ public ExpanderPage()
1819 private void ExpandDirectionComboBox_SelectionChanged ( object sender , SelectionChangedEventArgs e )
1920 {
2021 string expandDirection = e . AddedItems [ 0 ] . ToString ( ) ;
22+ var targetExpander = ( sender as FrameworkElement ) ? . Tag as Expander ;
23+ var headerRotate = ( ( targetExpander ? . Header as Border ) ? . Child as TextBlock ) ? . LayoutTransform as RotateTransform ;
24+ if ( targetExpander == null ) return ;
2125
2226 switch ( expandDirection )
2327 {
2428 case "Down" :
2529 default :
26- Expander1 . ExpandDirection = ExpandDirection . Down ;
27- Expander1 . VerticalAlignment = VerticalAlignment . Top ;
30+ targetExpander . ExpandDirection = ExpandDirection . Down ;
31+ targetExpander . VerticalAlignment = VerticalAlignment . Top ;
32+ if ( headerRotate != null ) headerRotate . Angle = 0 ;
2833 break ;
2934
3035 case "Up" :
31- Expander1 . ExpandDirection = ExpandDirection . Up ;
32- Expander1 . VerticalAlignment = VerticalAlignment . Bottom ;
36+ targetExpander . ExpandDirection = ExpandDirection . Up ;
37+ targetExpander . VerticalAlignment = VerticalAlignment . Bottom ;
38+ if ( headerRotate != null ) headerRotate . Angle = 0 ;
3339 break ;
3440
3541 case "Left" :
36- Expander1 . ExpandDirection = ExpandDirection . Left ;
37- Expander1 . HorizontalAlignment = HorizontalAlignment . Right ;
42+ targetExpander . ExpandDirection = ExpandDirection . Left ;
43+ targetExpander . HorizontalAlignment = HorizontalAlignment . Right ;
44+ if ( headerRotate != null ) headerRotate . Angle = 90 ;
3845 break ;
3946
4047 case "Right" :
41- Expander1 . ExpandDirection = ExpandDirection . Right ;
42- Expander1 . HorizontalAlignment = HorizontalAlignment . Left ;
43- break ;
44- }
45-
46- if ( this . IsLoaded )
47- {
48- UpdateExampleCode ( ) ;
49- }
50- }
51-
52- private void ExpandDirectionComboBox5_SelectionChanged ( object sender , SelectionChangedEventArgs e )
53- {
54- string expandDirection = e . AddedItems [ 0 ] . ToString ( ) ;
55-
56- switch ( expandDirection )
57- {
58- case "Down" :
59- default :
60- Expander5 . ExpandDirection = ExpandDirection . Down ;
61- Expander5 . VerticalAlignment = VerticalAlignment . Top ;
62- break ;
63-
64- case "Up" :
65- Expander5 . ExpandDirection = ExpandDirection . Up ;
66- Expander5 . VerticalAlignment = VerticalAlignment . Bottom ;
67- break ;
68-
69- case "Left" :
70- Expander5 . ExpandDirection = ExpandDirection . Left ;
71- Expander5 . HorizontalAlignment = HorizontalAlignment . Right ;
72- break ;
73-
74- case "Right" :
75- Expander5 . ExpandDirection = ExpandDirection . Right ;
76- Expander5 . HorizontalAlignment = HorizontalAlignment . Left ;
48+ targetExpander . ExpandDirection = ExpandDirection . Right ;
49+ targetExpander . HorizontalAlignment = HorizontalAlignment . Left ;
50+ if ( headerRotate != null ) headerRotate . Angle = 90 ;
7751 break ;
7852 }
7953
@@ -102,7 +76,7 @@ private void Page_Loaded(object sender, RoutedEventArgs e)
10276 } ;
10377 BindingOperations . SetBinding ( Substitution2 , ControlExampleSubstitution . ValueProperty , new Binding
10478 {
105- Source = ExpandDirectionComboBox ,
79+ Source = Expander1DirectionComboBox ,
10680 Path = new PropertyPath ( "SelectedValue" ) ,
10781 } ) ;
10882
@@ -129,50 +103,6 @@ private void Page_Loaded(object sender, RoutedEventArgs e)
129103 ObservableCollection < ControlExampleSubstitution > Substitutions = new ObservableCollection < ControlExampleSubstitution > { Substitution1 , Substitution2 , Substitution3 , Substitution4 } ;
130104 Example1 . Substitutions = Substitutions ;
131105
132- // Setup bindings for Example 5
133- ControlExampleSubstitution Substitution5 = new ControlExampleSubstitution
134- {
135- Key = "IsExpanded" ,
136- } ;
137- BindingOperations . SetBinding ( Substitution5 , ControlExampleSubstitution . ValueProperty , new Binding
138- {
139- Source = Expander5 ,
140- Path = new PropertyPath ( "IsExpanded" ) ,
141- } ) ;
142-
143- ControlExampleSubstitution Substitution6 = new ControlExampleSubstitution
144- {
145- Key = "ExpandDirection" ,
146- } ;
147- BindingOperations . SetBinding ( Substitution6 , ControlExampleSubstitution . ValueProperty , new Binding
148- {
149- Source = ExpandDirectionComboBox5 ,
150- Path = new PropertyPath ( "SelectedValue" ) ,
151- } ) ;
152-
153- ControlExampleSubstitution Substitution7 = new ControlExampleSubstitution
154- {
155- Key = "VerticalAlignment" ,
156- } ;
157- BindingOperations . SetBinding ( Substitution7 , ControlExampleSubstitution . ValueProperty , new Binding
158- {
159- Source = Expander5 ,
160- Path = new PropertyPath ( "VerticalAlignment" ) ,
161- } ) ;
162-
163- ControlExampleSubstitution Substitution8 = new ControlExampleSubstitution
164- {
165- Key = "HorizontalAlignment" ,
166- } ;
167- BindingOperations . SetBinding ( Substitution8 , ControlExampleSubstitution . ValueProperty , new Binding
168- {
169- Source = Expander5 ,
170- Path = new PropertyPath ( "HorizontalAlignment" ) ,
171- } ) ;
172-
173- ObservableCollection < ControlExampleSubstitution > Substitutions5 = new ObservableCollection < ControlExampleSubstitution > { Substitution5 , Substitution6 , Substitution7 , Substitution8 } ;
174- Example5 . Substitutions = Substitutions5 ;
175-
176106 UpdateExampleCode ( ) ;
177107 }
178108
@@ -183,18 +113,27 @@ public void UpdateExampleCode()
183113 Example1 . Xaml = Example1Xaml ;
184114 Example2 . Xaml = Example2Xaml ;
185115 Example3 . Xaml = Example3Xaml ;
186- // Example4.Xaml = Example4Xaml;
187- Example5 . Xaml = Example5Xaml ;
188- Example6 . Xaml = Example6Xaml ;
189- Example7 . Xaml = Example7Xaml ;
116+ Example4 . Xaml = Example4Xaml ;
190117 }
191118
192- public string Example1Xaml => $@ "
119+ public string Example1Xaml => RotateTransform_Example1Text . Angle == 0 ? $@ "
193120<Expander x:Name=""Expander1""
194121 Style=""{{StaticResource {{x:Static ui:ThemeKeys.ExpanderCardStyleKey}}}}""
195122 Content=""This is in the content""
196123 ExpandDirection=""{ Expander1 . ExpandDirection . ToString ( ) } ""
197124 Header=""This text is in the header"" />
125+ " : $@ "
126+ <Expander x:Name=""Expander1"" VerticalAlignment=""Top""
127+ Content=""This is in the content""
128+ ExpandDirection=""Down"" IsExpanded=""False"">
129+ <Expander.Header>
130+ <TextBlock Text=""This text is in the header"" FontWeight=""Bold"">
131+ <TextBlock.LayoutTransform>
132+ <RotateTransform Angle=""{ RotateTransform_Example1Text . Angle } ""/>
133+ </TextBlock.LayoutTransform>
134+ </TextBlock>
135+ </Expander.Header>
136+ </Expander>
198137" ;
199138
200139 public string Example2Xaml => $@ "
@@ -221,47 +160,12 @@ public void UpdateExampleCode()
221160</Expander>
222161" ;
223162
224- // public string Example4Xaml => $@"
225- // <Expander Width=""500""
226- // Content=""This is in the content""
227- // ExpandDirection=""Down""
228- // Header=""This text is in the header""
229- // HorizontalContentAlignment=""Left"" />
230- // ";
231-
232- public string Example5Xaml => $@ "
233- <Expander x:Name=""Expander5""
234- VerticalAlignment=""Top""
163+ public string Example4Xaml => $@ "
164+ <Expander x:Name=""Expander4""
235165 Content=""This is in the content""
236- ExpandDirection=""{ Expander5 . ExpandDirection . ToString ( ) } ""
237- Header=""This text is in the header""
238- IsExpanded=""False"" />
239- " ;
240-
241- public string Example6Xaml => $@ "
242- <Expander x:Name=""Expander6"">
243- <Expander.Header>
244- <ToggleButton Content=""This is a ToggleButton in the header"" />
245- </Expander.Header>
246- <Expander.Content>
247- <Grid>
248- <Button Margin=""15"" Content=""This is a Button in the content"" />
249- </Grid>
250- </Expander.Content>
251- </Expander>
252- " ;
253-
254- public string Example7Xaml => $@ "
255- <Expander Width=""500""
256- Padding=""0""
257- HorizontalContentAlignment=""Left"">
258- <Expander.Header>
259- <ToggleButton HorizontalAlignment=""Center"" Content=""This ToggleButton is centered"" />
260- </Expander.Header>
261- <Expander.Content>
262- <Button Margin=""4"" Content=""This Button is left aligned"" />
263- </Expander.Content>
264- </Expander>
166+ Style=""{{StaticResource {{x:Static ui:ThemeKeys.ExpanderCardStyleKey}}}}""
167+ ExpandDirection=""{ Expander4 . ExpandDirection . ToString ( ) } ""
168+ Header=""This text is in the header"" />
265169" ;
266170
267171 #endregion
0 commit comments