• <tfoot id='sBb2X'></tfoot>

    <legend id='sBb2X'><style id='sBb2X'><dir id='sBb2X'><q id='sBb2X'></q></dir></style></legend>
      <bdo id='sBb2X'></bdo><ul id='sBb2X'></ul>
    <i id='sBb2X'><tr id='sBb2X'><dt id='sBb2X'><q id='sBb2X'><span id='sBb2X'><b id='sBb2X'><form id='sBb2X'><ins id='sBb2X'></ins><ul id='sBb2X'></ul><sub id='sBb2X'></sub></form><legend id='sBb2X'></legend><bdo id='sBb2X'><pre id='sBb2X'><center id='sBb2X'></center></pre></bdo></b><th id='sBb2X'></th></span></q></dt></tr></i><div id='sBb2X'><tfoot id='sBb2X'></tfoot><dl id='sBb2X'><fieldset id='sBb2X'></fieldset></dl></div>

    <small id='sBb2X'></small><noframes id='sBb2X'>

      1. 自适应触发器和数据模板

        时间:2023-09-15
        <tfoot id='fy9j5'></tfoot>
          <tbody id='fy9j5'></tbody>

          <legend id='fy9j5'><style id='fy9j5'><dir id='fy9j5'><q id='fy9j5'></q></dir></style></legend>
        1. <small id='fy9j5'></small><noframes id='fy9j5'>

          • <i id='fy9j5'><tr id='fy9j5'><dt id='fy9j5'><q id='fy9j5'><span id='fy9j5'><b id='fy9j5'><form id='fy9j5'><ins id='fy9j5'></ins><ul id='fy9j5'></ul><sub id='fy9j5'></sub></form><legend id='fy9j5'></legend><bdo id='fy9j5'><pre id='fy9j5'><center id='fy9j5'></center></pre></bdo></b><th id='fy9j5'></th></span></q></dt></tr></i><div id='fy9j5'><tfoot id='fy9j5'></tfoot><dl id='fy9j5'><fieldset id='fy9j5'></fieldset></dl></div>

                  <bdo id='fy9j5'></bdo><ul id='fy9j5'></ul>
                  本文介绍了自适应触发器和数据模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  AdaptiveTrigger 可以在 DataTemplate 中工作吗?

                  Will AdaptiveTrigger work in a DataTemplate?

                  这是我用来自定义 ShellNavigation 的代码,除了视觉状态外,它工作正常.他们不会触发任何事情.

                  That's my code i'm using to customize my ShellNavigation, it is working fine except the visual states. They will not trigger anything.

                  <shell:ShellHeadView x:Key="ShellHeadView_01">
                      <shell:ShellHeadView.ContentTemplate>
                          <DataTemplate>
                              <Grid Margin="20,0">
                                  <VisualStateManager.VisualStateGroups>
                                      <VisualStateGroup>
                                          <VisualState x:Name="GreenBackgroundVisualState">
                                              <VisualState.Setters>
                                                  <Setter Target="headViewLeft.Background" Value="Green" />
                                              </VisualState.Setters>
                                              <VisualState.StateTriggers>
                                                  <AdaptiveTrigger MinWindowWidth="1000"/>
                                              </VisualState.StateTriggers>
                                          </VisualState>
                                          <VisualState x:Name="OrangeBackgroundVisualState">
                                              <VisualState.Setters>
                                                  <Setter Target="headViewLeft.Background" Value="Orange" />
                                              </VisualState.Setters>
                                              <VisualState.StateTriggers>
                                                  <AdaptiveTrigger MinWindowWidth="2000"/>
                                              </VisualState.StateTriggers>
                                          </VisualState>
                                          <VisualState x:Name="RedBackgroundVisualState">
                                              <VisualState.Setters>
                                                  <Setter Target="headViewLeft.Background" Value="Red" />
                                              </VisualState.Setters>
                                              <VisualState.StateTriggers>
                                                  <AdaptiveTrigger MinWindowWidth="3000"/>
                                              </VisualState.StateTriggers>
                                          </VisualState>
                                      </VisualStateGroup>
                                  </VisualStateManager.VisualStateGroups>
                                  <Grid.ColumnDefinitions>
                                      <ColumnDefinition Width="Auto"/>
                                      <ColumnDefinition/>
                                  </Grid.ColumnDefinitions>
                                  <Grid Grid.Column="0" x:Name="headViewLeft" Width="100" Height="90">
                  
                                  </Grid>
                  

                  推荐答案

                  尝试像这样将您的 DataTemplate 包装在 UserControl 中 -

                  Try wrapping your DataTemplate inside a UserControl like this -

                  <DataTemplate>
                      <UserControl>
                          <Grid>
                              <VisualStateManager.VisualStateGroups>
                              ...
                          </Grid>
                      </UserControl>
                  </DataTemplate>
                  

                  <小时>

                  看起来任何具有 Content 属性的 Control 都可以工作.这就是 UserControl 起作用的原因,ContentControl 也是如此.


                  Looks like any Control that has got a Content property will work. That's why UserControl works, so does a ContentControl.

                  因此,如果您将 UserControl 替换为 ContentControl 并给它一个空的 Style.它也应该可以工作.

                  So if you replace the UserControl with a ContentControl and give it an empty Style. It should work too.

                  <Style x:Key="EmptyContentControlStyle" TargetType="ContentControl">
                      <Setter Property="Template">
                          <Setter.Value>
                              <ControlTemplate TargetType="ContentControl" />
                          </Setter.Value>
                      </Setter>
                  </Style>
                  
                  <DataTemplate>
                      <ContentControl Style="{StaticResource EmptyContentControlStyle}">
                          <Grid>
                              <VisualStateManager.VisualStateGroups>
                              ...
                          </Grid>
                      </ContentControl>
                  </DataTemplate>
                  

                  这篇关于自适应触发器和数据模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在 Windows 10 Universal 中获取设备的唯一标识符? 下一篇:无法加载文件或程序集“Newtonsoft.Json,Version=9.0.0.0,Culture=neutral,P

                  相关文章

                    <tfoot id='x1XW1'></tfoot>
                  1. <small id='x1XW1'></small><noframes id='x1XW1'>

                    1. <legend id='x1XW1'><style id='x1XW1'><dir id='x1XW1'><q id='x1XW1'></q></dir></style></legend>
                      • <bdo id='x1XW1'></bdo><ul id='x1XW1'></ul>
                    2. <i id='x1XW1'><tr id='x1XW1'><dt id='x1XW1'><q id='x1XW1'><span id='x1XW1'><b id='x1XW1'><form id='x1XW1'><ins id='x1XW1'></ins><ul id='x1XW1'></ul><sub id='x1XW1'></sub></form><legend id='x1XW1'></legend><bdo id='x1XW1'><pre id='x1XW1'><center id='x1XW1'></center></pre></bdo></b><th id='x1XW1'></th></span></q></dt></tr></i><div id='x1XW1'><tfoot id='x1XW1'></tfoot><dl id='x1XW1'><fieldset id='x1XW1'></fieldset></dl></div>