English 中文(简体)
• 如何使世界森林论坛发挥作用 扩大后向上扩展,同时保持头盔固定不变
原标题:How to make WPF Expander expand upwards while keeping the header fixed

我正试图设立一个扩大小组,由该负责人固定下来,其内容出现在上面任何其它控制线上。 <>ExpandDirection=“Up”,并将扩大成员放在Canvas实现其中一半的目标——内容比头部扩大,并超出其他控制(尽管下文),但头部向下移动。

是否有办法这样做,但还是要让头脑处于固定的位置,以便内容能够结束上述过度控制?

这是我迄今为止所阐明的:

<Window x:Class="Sandbox.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="900" Width="1100">
  <StackPanel>

    <StackPanel Margin="20,0,0,0">
      <RadioButton Content="Choice One"/>
      <RadioButton Content="Choice Two"/>
      <RadioButton Content="Choice Three"/>
      <RadioButton Content="Choice Four"/>
      <RadioButton Content="Choice Five"/>
      <RadioButton Content="Choice Six"/>
    </StackPanel>

    <Canvas MinHeight="25" Panel.ZIndex="99">
      <Expander Header="This must stay fixed" ExpandDirection="Up" Width="175">
        <Grid Background="Cornsilk">
          <Grid.BitmapEffect>
            <DropShadowBitmapEffect />
          </Grid.BitmapEffect>

          <TextBlock TextWrapping="Wrap" Margin="5">
            This must expand upwards, not downwards.
            The header must remain exactly where it is.
            This TextBlock must appear above the header
            and overlay the top radio buttons instead.
          </TextBlock>
        </Grid>
      </Expander>
    </Canvas>

    <StackPanel Margin="20,0,0,0">
      <RadioButton Content="Choice One"/>
      <RadioButton Content="Choice Two"/>
      <RadioButton Content="Choice Three"/>
      <RadioButton Content="Choice Four"/>
      <RadioButton Content="Choice Five"/>
      <RadioButton Content="Choice Six"/>
    </StackPanel>

  </StackPanel>
</Window>
最佳回答

你可以使用ToggleButton和Popup,而不是扩大:

<Canvas MinHeight="25" Panel.ZIndex="99">
  <ToggleButton x:Name="toggle" Content="This must stay fixed" Width="175" />
  <Popup Placement="Top" PlacementTarget="{Binding ElementName=toggle}"
         IsOpen="{Binding ElementName=toggle, Path=IsChecked}">
      <Grid Background="Cornsilk" Width="175">
          <Grid.BitmapEffect>
              <DropShadowBitmapEffect />
          </Grid.BitmapEffect>

          <TextBlock TextWrapping="Wrap" Margin="5">
            This must expand upwards, not downwards.
            The header must remain exactly where it is.
            This TextBlock must appear above the header
            and overlay the top radio buttons instead.
          </TextBlock>
      </Grid>  
  </Popup>
</Canvas>
问题回答

另一种方式是使用CayBox控制而不是ToggleButton。 很容易使用例如,隐藏箱子。 负差价的纸浆。 而且,你不需要关注边界等。 在某些情况下,这种情况非常容易。





相关问题
WPF convert 2d mouse click into 3d space

I have several geometry meshes in my Viewport3D, these have bounds of (w:1800, h:500, d:25). When a user clicks in the middle of the mesh, I want the Point3D of (900, 500, 25)... How can I achieve ...

Editing a xaml icons or images

Is it possible to edit a xaml icons or images in the expression design or using other tools? Is it possible to import a xaml images (that e.g you have exported) in the expression designer for editing?...

WPF: writing smoke tests using ViewModels

I am considering to write smoke tests for our WPF application. The question that I am faced is: should we use UI automation( or some other technology that creates a UI script), or is it good enough to ...

WPF - MVVM - NHibernate Validation

Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...

How do WPF Markup Extensions raise compile errors?

Certain markup extensions raise compile errors. For example StaticExtension (x:Static) raises a compile error if the referenced class cannot be found. Anyone know the mechanism for this? Is it baked ...

WPF design-time context menu

I am trying to create a custom wpf control, I m wondering how I can add some design-time features. I ve googled and can t seem to get to my goal. So here s my simple question, how can I add an entry ...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签