【问题标题】:Visibile/collapsed button on a grid view in C# WP8 DevelopmentC# WP8 开发中网格视图上的可见/折叠按钮
【发布时间】:2013-12-12 08:51:38
【问题描述】:

是的,我是 windows phone 8 dev 的新手。 我有问题来控制位于该网格上的按钮上的网格视图可见性和可见性.. 这是我的 xaml 视图快照..

http://www.4shared.com/photo/Hu1FVCdn/wp8.html

这是我的 Xaml 视图...我在左侧有一个网格视图和按钮。(1,2,3,4,5)...这些按钮的可见性已折叠...当交易按钮被点击 II 喜欢所有可见的按钮..但是我的屏幕上显示了 2,3 个错误..

这是我的 xaml.cs 代码..

  public main()
    {
        InitializeComponent();

    }
    private void Button_Click(object sender, RoutedEventArgs e)
    {
        NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
    }
    private void Grid_View_Btn_1_Click(object sender, System.Windows.RoutedEventArgs e)
    {

       // a.Visible = !a.Visible;
         a.Visibility = Visibility.Visible; //Also possible to Collapse (hide). 
      b.Visibility = Visibility.Visible; //Also possible to Collapse (hide).
      c.Visibility = Visibility.Visible; //Also possible to Collapse (hide).
       d.Visibility = Visibility.Visible; //Also possible to Collapse (hide).
      e.Visibility = Visibility.Visible; //Also possible to Collapse (hide).

        // TODO: Add event handler implementation here.
    }

这是我的 xaml 代码..

     <Grid x:Name="grid" Height="618" Margin="6,147,0,0" Width="112" HorizontalAlignment="Left" VerticalAlignment="Top">
            <Grid.Background>
                <ImageBrush Stretch="Fill" ImageSource="pannel.png"/>
            </Grid.Background>
            <Button x:Name="a" Content="1" HorizontalAlignment="Left" Margin="-7,-11,-11,563" VerticalAlignment="Bottom" Width="130" RenderTransformOrigin="0.636,0.638" Height="66" BorderThickness="0" d:IsHidden="True">
                <Button.Background>
                    <ImageBrush Stretch="Fill" ImageSource="pannel_btn_unselected.png"/>
                </Button.Background>
            </Button>
            <Button x:Name="b" Content="2" HorizontalAlignment="Left" Margin="-7,0,-11,519" VerticalAlignment="Bottom" Width="130" RenderTransformOrigin="0.636,0.638" Height="66" BorderThickness="0" d:IsHidden="True">
                <Button.Background>
                    <ImageBrush Stretch="Fill" ImageSource="pannel_btn_unselected.png"/>
                </Button.Background>
            </Button>
            <Button x:Name="c" Content="3" HorizontalAlignment="Left" Margin="-7,0,-11,475" VerticalAlignment="Bottom" Width="130" RenderTransformOrigin="0.636,0.638" Height="66" BorderThickness="0" d:IsHidden="True">
                <Button.Background>
                    <ImageBrush Stretch="Fill" ImageSource="pannel_btn_unselected.png"/>
                </Button.Background>
            </Button>
            <Button x:Name="d" Content="4" HorizontalAlignment="Left" Margin="-7,0,-11,431" VerticalAlignment="Bottom" Width="130" RenderTransformOrigin="0.636,0.638" Height="66" BorderThickness="0" d:IsHidden="True">
                <Button.Background>
                    <ImageBrush Stretch="Fill" ImageSource="pannel_btn_unselected.png"/>
                </Button.Background>
            </Button>
            <Button x:Name="e" Content="5" HorizontalAlignment="Left" Margin="-7,0,-11,387" VerticalAlignment="Bottom" Width="130" RenderTransformOrigin="0.636,0.638" Height="66" BorderThickness="0" d:IsHidden="True">
                <Button.Background>
                    <ImageBrush Stretch="Fill" ImageSource="pannel_btn_unselected.png"/>
                </Button.Background>
            </Button>
        </Grid>

出现的错误是这个“错误:'System.Windows.RoutedEventArgs'不包含'Visibility'的定义,并且没有扩展方法'Visibility'接受'System.Windows类型的第一个参数。可以找到 RoutedEventArgs'(您是否缺少 using 指令或程序集引用?)"

请帮我解决我的问题... 我只是想在点击“交易”按钮后看到该按钮...!!

【问题讨论】:

    标签: c# xaml windows-phone-8


    【解决方案1】:

    您的事件处理程序 Grid_View_Btn_1_Click 有一个参数“e”。当引用“e”时,处理程序将使用参数“e”,而不是控件“e”。将 handlers 参数重命名为“e2”或类似名称。

    【讨论】:

    • 或者更好的是,将按钮命名为 a - e 以外的其他名称
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-12
    • 1970-01-01
    • 2021-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多