2017-09-29 61 views
0

我有一個userControl,它具有以下xaml,我正在不同的UserControls中使用它們。問題是隻有一個滑塊可見時,滑塊的方向不與滑塊中心對齊。但是當所有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並設置能見度取決於你能提供給觸發數據。

相關問題