2017-09-29 1 views
0

다른 UserControls에서 재사용하고있는 다음 xaml과 userControl이 있습니다. 문제는 슬라이더가 하나 밖에 보이지 않을 때 슬라이더의 방향이 슬라이더의 가운데에 정렬되어 있지 않다는 것입니다. 그러나 4 개의 슬라이더가 모두 표시되면 버튼의 방향이 슬라이더에 중앙 정렬됩니다. 마진을 설정하는 것은 해결책이 아닙니다. 나는 컨테이너를 가지고 놀아 보았지만 행운은 없었습니다. 도와주세요. BRSliderStyle 및 BRButtonStyle이라는 리소스를 사용하여 두 컨트롤 모두에서 가로 및 세로 정렬을 가운데로 설정합니다.서로 다른보기에서 단추가 바뀌는 정렬

<UserControl> 
<UserControl.Resources> 
     <BooleanToVisibilityConverter 
      x:Key="visibleConverter"></BooleanToVisibilityConverter> 
    </UserControl.Resources> 
    <Grid> 
      <Grid.RowDefinitions> 
       <RowDefinition 
        Height="*"></RowDefinition> 
       <RowDefinition 
        Height="Auto"></RowDefinition> 
      </Grid.RowDefinitions> 
      <StackPanel 
       Orientation="Vertical" Grid.Row="0" 
       DockPanel.Dock="Top"> 
      <helper:BRSliderUserControl 
       x:Name="ChartAxisSliderControl" 
       SliderValuesDictionary="{Binding m_ChartAxisLabelTextSizeSliderAssociatedDictionary,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" 
       DefaultSliderValue="{Binding m_ChartAxisTextSizeSliderDefaultValue,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" 
       AnalysisType="{Binding AnalysisTypeValue,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" 
       ChartAssociatedProperty="{x:Static dd:ChartAssociatedProperties.ChartAxisLabelsTextSize}" 
       SessionIdProperty="{Binding SessionIdProperty,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" 
       Visibility="{Binding Path=DataContext.ShowChartAxisSlider,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}},Converter={StaticResource visibleConverter}}"></helper:BRSliderUserControl> 
      <helper:BRSliderUserControl 

       x:Name="ChartMarkerSliderControl" 
       Margin="0,20,0,0" 
       SliderValuesDictionary="{Binding m_ChartMarkerSizeSliderAssociatedDictionary,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" 
       DefaultSliderValue="{Binding m_ChartMarkerSizeSliderDefaultValue,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" 
       AnalysisType="{Binding AnalysisTypeValue,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" 
       ChartAssociatedProperty="{x:Static dd:ChartAssociatedProperties.ChartMarkersSize}" 
       SessionIdProperty="{Binding SessionIdProperty,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" 
       Visibility="{Binding Path= DataContext.ShowChartMarkerSlider,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}},Converter={StaticResource visibleConverter}}"></helper:BRSliderUserControl> 
      <helper:BRSliderUserControl 

       x:Name="ChartDataLabelSliderControl" 
       Margin="0,20,0,0" 
       SliderValuesDictionary="{Binding m_ChartDataLabelTextSizeSliderAssociatedDictionary,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" 
       DefaultSliderValue="{Binding m_ChartDataLabelTextSizeSliderDefaultValue,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" 
       AnalysisType="{Binding AnalysisTypeValue,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" 
       ChartAssociatedProperty="{x:Static dd:ChartAssociatedProperties.ChartDataLabelsTextSize}" 
       SessionIdProperty="{Binding SessionIdProperty,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" 
       Visibility="{Binding Path=DataContext.ShowChartDataLabelSlider,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}},Converter={StaticResource visibleConverter}}"></helper:BRSliderUserControl> 
      <helper:BRSliderUserControl 

       x:Name="ChartUpDownSliderControl" 
       Margin="0,20,0,0" 
       SliderValuesDictionary="{Binding m_ChartDataLabelPlacementSliderAssociatedDictionary,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" 
       DefaultSliderValue="{Binding m_ChartDataLabelPlacementSliderDefaultValue,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" 
       AnalysisType="{Binding AnalysisTypeValue,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" 
       ChartAssociatedProperty="{x:Static dd:ChartAssociatedProperties.ChartDataLabelsPlacementTopOrBottom}" 
       SessionIdProperty="{Binding SessionIdProperty,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" 
       Visibility="{Binding Path=DataContext.ShowChartUpOrDownSlider,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}},Converter={StaticResource visibleConverter}}"></helper:BRSliderUserControl> 
      </StackPanel> 
      <StackPanel 
       Grid.Row="1" 
       HorizontalAlignment="Center" Margin="0,20,0,0"> 
      <Button 
       x:Name="SaveDefaultSettings" 
       Content="{StaticResource SaveAsDefault}"  
       Click="SaveDefaultSettings_Click" 
       Width="180"></Button> 
      </StackPanel> 
     </Grid> 
</UserControl 
+1

나는 당신의 질문을 이해하지 못합니다. 달성하고자하는 것을 보여주는 스크린 샷을 추가 할 수 있습니까? –

답변

0

는 예를 들어, 당신은 DataTrigger를 사용하고 당신이 방아쇠에게 제공 할 수있는 데이터에 의존 가시성을 설정할 수 있습니다.

관련 문제