Popup dynamic reposition with Expander Style












0















I am really looking for the good property to get the Popup follow the expander when the window is resized.



The expander and the popup are define into a Style, but if the Expander moves right with the window but not the popup



If we look at the controltemplate:



<ControlTemplate x:Key="RightExpander" TargetType="{x:Type Expander}">
<Border SnapsToDevicePixels="true" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
CornerRadius="3">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="0"/>
</Grid.RowDefinitions>

<ToggleButton Width="{TemplateBinding ActualWidth}" Margin="0,1,0,1" MinHeight="0" MinWidth="30" x:Name="HeaderSite"
Style="{StaticResource LeftPanelCollpasedButtonStyle}" Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}"
FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}"
FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
Padding="{TemplateBinding Padding}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" DockPanel.Dock="Top"/>

<Popup x:Name="popup" AllowsTransparency="False" Margin="0,1,0,1" IsOpen="False" Placement="Bottom" PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}">



<Grid >


<ContentControl x:Name="shadow" Visibility="Collapsed" HorizontalAlignment="Stretch" Style="{DynamicResource ShadowTemplate}"
VerticalAlignment="Stretch" Content="ContentControl" Opacity="1"
Margin="2,0,2,0" Foreground="#FF000000"/>
<ContentPresenter Opacity="1" MinWidth="220" HorizontalAlignment="Left" Margin="0,0,0,0" x:Name="ExpandSite" Focusable="false" Visibility="Collapsed" VerticalAlignment="Top" />
</Grid>

</Popup>
</Grid>
</Border>
<ControlTemplate.Triggers>


<Trigger Property="IsExpanded" Value="true">
<Setter TargetName="shadow" Property="Visibility" Value="Visible"/>
<Setter TargetName="popup" Property="Placement" Value="Right"/>
<Setter TargetName="popup" Property="HorizontalOffset" Value="-5"/>
<Setter TargetName="popup" Property="IsOpen" Value="true"/>
<Setter TargetName="ExpandSite" Property="Margin" Value="5,5,5,5"/>


<Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
</Trigger>


<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
<Setter TargetName="shadow" Property="Visibility" Value="Visible"/>
<Setter TargetName="popup" Property="Placement" Value="Right"/>
<Setter TargetName="popup" Property="HorizontalOffset" Value="-5"/>
<Setter TargetName="popup" Property="IsOpen" Value="true"/>
<Setter TargetName="ExpandSite" Property="Margin" Value="5,5,5,5"/>
<Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
</Trigger>




</ControlTemplate.Triggers>
</ControlTemplate>


The line where the Popup is defined indicate "Placement" and "PlacementTarget" but it doesnt have an impact on the behaviour, whatever I changed.
I think I need some triggers, but I don't know where to begin with. If someone could help me it would be very nice.



I use the controltemplate in my code in this way :



<Expander Header="MyExpander" Grid.Row="0" Style="{DynamicResource OutlookStyleExpanderStyle}" IsExpanded="true", Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" x:Name="proc" HorizontalAlignment="Left" Width="350" Margin="0,0,0,0">                                      



<StackPanel Orientation="Vertical" Grid.Row="0" >
<StackPanel Orientation="Horizontal">
<Label FontSize="9" >LabelA</Label>
<TextBox Width="30"/>
<Label FontSize="9" >LabelB</Label>
<TextBox Width="30"/>
</StackPanel>

</Expander>









share|improve this question























  • Looking trough a lot of differents help I found these post really useful : stackoverflow.com/questions/1600218/… But how to make the same frome the ControlTemplate ?

    – Magus
    Nov 21 '18 at 10:52


















0















I am really looking for the good property to get the Popup follow the expander when the window is resized.



The expander and the popup are define into a Style, but if the Expander moves right with the window but not the popup



If we look at the controltemplate:



<ControlTemplate x:Key="RightExpander" TargetType="{x:Type Expander}">
<Border SnapsToDevicePixels="true" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
CornerRadius="3">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="0"/>
</Grid.RowDefinitions>

<ToggleButton Width="{TemplateBinding ActualWidth}" Margin="0,1,0,1" MinHeight="0" MinWidth="30" x:Name="HeaderSite"
Style="{StaticResource LeftPanelCollpasedButtonStyle}" Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}"
FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}"
FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
Padding="{TemplateBinding Padding}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" DockPanel.Dock="Top"/>

<Popup x:Name="popup" AllowsTransparency="False" Margin="0,1,0,1" IsOpen="False" Placement="Bottom" PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}">



<Grid >


<ContentControl x:Name="shadow" Visibility="Collapsed" HorizontalAlignment="Stretch" Style="{DynamicResource ShadowTemplate}"
VerticalAlignment="Stretch" Content="ContentControl" Opacity="1"
Margin="2,0,2,0" Foreground="#FF000000"/>
<ContentPresenter Opacity="1" MinWidth="220" HorizontalAlignment="Left" Margin="0,0,0,0" x:Name="ExpandSite" Focusable="false" Visibility="Collapsed" VerticalAlignment="Top" />
</Grid>

</Popup>
</Grid>
</Border>
<ControlTemplate.Triggers>


<Trigger Property="IsExpanded" Value="true">
<Setter TargetName="shadow" Property="Visibility" Value="Visible"/>
<Setter TargetName="popup" Property="Placement" Value="Right"/>
<Setter TargetName="popup" Property="HorizontalOffset" Value="-5"/>
<Setter TargetName="popup" Property="IsOpen" Value="true"/>
<Setter TargetName="ExpandSite" Property="Margin" Value="5,5,5,5"/>


<Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
</Trigger>


<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
<Setter TargetName="shadow" Property="Visibility" Value="Visible"/>
<Setter TargetName="popup" Property="Placement" Value="Right"/>
<Setter TargetName="popup" Property="HorizontalOffset" Value="-5"/>
<Setter TargetName="popup" Property="IsOpen" Value="true"/>
<Setter TargetName="ExpandSite" Property="Margin" Value="5,5,5,5"/>
<Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
</Trigger>




</ControlTemplate.Triggers>
</ControlTemplate>


The line where the Popup is defined indicate "Placement" and "PlacementTarget" but it doesnt have an impact on the behaviour, whatever I changed.
I think I need some triggers, but I don't know where to begin with. If someone could help me it would be very nice.



I use the controltemplate in my code in this way :



<Expander Header="MyExpander" Grid.Row="0" Style="{DynamicResource OutlookStyleExpanderStyle}" IsExpanded="true", Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" x:Name="proc" HorizontalAlignment="Left" Width="350" Margin="0,0,0,0">                                      



<StackPanel Orientation="Vertical" Grid.Row="0" >
<StackPanel Orientation="Horizontal">
<Label FontSize="9" >LabelA</Label>
<TextBox Width="30"/>
<Label FontSize="9" >LabelB</Label>
<TextBox Width="30"/>
</StackPanel>

</Expander>









share|improve this question























  • Looking trough a lot of differents help I found these post really useful : stackoverflow.com/questions/1600218/… But how to make the same frome the ControlTemplate ?

    – Magus
    Nov 21 '18 at 10:52
















0












0








0








I am really looking for the good property to get the Popup follow the expander when the window is resized.



The expander and the popup are define into a Style, but if the Expander moves right with the window but not the popup



If we look at the controltemplate:



<ControlTemplate x:Key="RightExpander" TargetType="{x:Type Expander}">
<Border SnapsToDevicePixels="true" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
CornerRadius="3">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="0"/>
</Grid.RowDefinitions>

<ToggleButton Width="{TemplateBinding ActualWidth}" Margin="0,1,0,1" MinHeight="0" MinWidth="30" x:Name="HeaderSite"
Style="{StaticResource LeftPanelCollpasedButtonStyle}" Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}"
FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}"
FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
Padding="{TemplateBinding Padding}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" DockPanel.Dock="Top"/>

<Popup x:Name="popup" AllowsTransparency="False" Margin="0,1,0,1" IsOpen="False" Placement="Bottom" PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}">



<Grid >


<ContentControl x:Name="shadow" Visibility="Collapsed" HorizontalAlignment="Stretch" Style="{DynamicResource ShadowTemplate}"
VerticalAlignment="Stretch" Content="ContentControl" Opacity="1"
Margin="2,0,2,0" Foreground="#FF000000"/>
<ContentPresenter Opacity="1" MinWidth="220" HorizontalAlignment="Left" Margin="0,0,0,0" x:Name="ExpandSite" Focusable="false" Visibility="Collapsed" VerticalAlignment="Top" />
</Grid>

</Popup>
</Grid>
</Border>
<ControlTemplate.Triggers>


<Trigger Property="IsExpanded" Value="true">
<Setter TargetName="shadow" Property="Visibility" Value="Visible"/>
<Setter TargetName="popup" Property="Placement" Value="Right"/>
<Setter TargetName="popup" Property="HorizontalOffset" Value="-5"/>
<Setter TargetName="popup" Property="IsOpen" Value="true"/>
<Setter TargetName="ExpandSite" Property="Margin" Value="5,5,5,5"/>


<Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
</Trigger>


<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
<Setter TargetName="shadow" Property="Visibility" Value="Visible"/>
<Setter TargetName="popup" Property="Placement" Value="Right"/>
<Setter TargetName="popup" Property="HorizontalOffset" Value="-5"/>
<Setter TargetName="popup" Property="IsOpen" Value="true"/>
<Setter TargetName="ExpandSite" Property="Margin" Value="5,5,5,5"/>
<Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
</Trigger>




</ControlTemplate.Triggers>
</ControlTemplate>


The line where the Popup is defined indicate "Placement" and "PlacementTarget" but it doesnt have an impact on the behaviour, whatever I changed.
I think I need some triggers, but I don't know where to begin with. If someone could help me it would be very nice.



I use the controltemplate in my code in this way :



<Expander Header="MyExpander" Grid.Row="0" Style="{DynamicResource OutlookStyleExpanderStyle}" IsExpanded="true", Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" x:Name="proc" HorizontalAlignment="Left" Width="350" Margin="0,0,0,0">                                      



<StackPanel Orientation="Vertical" Grid.Row="0" >
<StackPanel Orientation="Horizontal">
<Label FontSize="9" >LabelA</Label>
<TextBox Width="30"/>
<Label FontSize="9" >LabelB</Label>
<TextBox Width="30"/>
</StackPanel>

</Expander>









share|improve this question














I am really looking for the good property to get the Popup follow the expander when the window is resized.



The expander and the popup are define into a Style, but if the Expander moves right with the window but not the popup



If we look at the controltemplate:



<ControlTemplate x:Key="RightExpander" TargetType="{x:Type Expander}">
<Border SnapsToDevicePixels="true" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
CornerRadius="3">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="0"/>
</Grid.RowDefinitions>

<ToggleButton Width="{TemplateBinding ActualWidth}" Margin="0,1,0,1" MinHeight="0" MinWidth="30" x:Name="HeaderSite"
Style="{StaticResource LeftPanelCollpasedButtonStyle}" Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}"
FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}"
FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
Padding="{TemplateBinding Padding}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" DockPanel.Dock="Top"/>

<Popup x:Name="popup" AllowsTransparency="False" Margin="0,1,0,1" IsOpen="False" Placement="Bottom" PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}">



<Grid >


<ContentControl x:Name="shadow" Visibility="Collapsed" HorizontalAlignment="Stretch" Style="{DynamicResource ShadowTemplate}"
VerticalAlignment="Stretch" Content="ContentControl" Opacity="1"
Margin="2,0,2,0" Foreground="#FF000000"/>
<ContentPresenter Opacity="1" MinWidth="220" HorizontalAlignment="Left" Margin="0,0,0,0" x:Name="ExpandSite" Focusable="false" Visibility="Collapsed" VerticalAlignment="Top" />
</Grid>

</Popup>
</Grid>
</Border>
<ControlTemplate.Triggers>


<Trigger Property="IsExpanded" Value="true">
<Setter TargetName="shadow" Property="Visibility" Value="Visible"/>
<Setter TargetName="popup" Property="Placement" Value="Right"/>
<Setter TargetName="popup" Property="HorizontalOffset" Value="-5"/>
<Setter TargetName="popup" Property="IsOpen" Value="true"/>
<Setter TargetName="ExpandSite" Property="Margin" Value="5,5,5,5"/>


<Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
</Trigger>


<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
<Setter TargetName="shadow" Property="Visibility" Value="Visible"/>
<Setter TargetName="popup" Property="Placement" Value="Right"/>
<Setter TargetName="popup" Property="HorizontalOffset" Value="-5"/>
<Setter TargetName="popup" Property="IsOpen" Value="true"/>
<Setter TargetName="ExpandSite" Property="Margin" Value="5,5,5,5"/>
<Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
</Trigger>




</ControlTemplate.Triggers>
</ControlTemplate>


The line where the Popup is defined indicate "Placement" and "PlacementTarget" but it doesnt have an impact on the behaviour, whatever I changed.
I think I need some triggers, but I don't know where to begin with. If someone could help me it would be very nice.



I use the controltemplate in my code in this way :



<Expander Header="MyExpander" Grid.Row="0" Style="{DynamicResource OutlookStyleExpanderStyle}" IsExpanded="true", Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" x:Name="proc" HorizontalAlignment="Left" Width="350" Margin="0,0,0,0">                                      



<StackPanel Orientation="Vertical" Grid.Row="0" >
<StackPanel Orientation="Horizontal">
<Label FontSize="9" >LabelA</Label>
<TextBox Width="30"/>
<Label FontSize="9" >LabelB</Label>
<TextBox Width="30"/>
</StackPanel>

</Expander>






xaml






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 10:11









MagusMagus

123




123













  • Looking trough a lot of differents help I found these post really useful : stackoverflow.com/questions/1600218/… But how to make the same frome the ControlTemplate ?

    – Magus
    Nov 21 '18 at 10:52





















  • Looking trough a lot of differents help I found these post really useful : stackoverflow.com/questions/1600218/… But how to make the same frome the ControlTemplate ?

    – Magus
    Nov 21 '18 at 10:52



















Looking trough a lot of differents help I found these post really useful : stackoverflow.com/questions/1600218/… But how to make the same frome the ControlTemplate ?

– Magus
Nov 21 '18 at 10:52







Looking trough a lot of differents help I found these post really useful : stackoverflow.com/questions/1600218/… But how to make the same frome the ControlTemplate ?

– Magus
Nov 21 '18 at 10:52














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53390668%2fpopup-dynamic-reposition-with-expander-style%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53390668%2fpopup-dynamic-reposition-with-expander-style%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

SQL update select statement

WPF add header to Image with URL pettitions [duplicate]