在wp7中从后端获取控制权

发布于 2024-12-28 12:49:18 字数 3660 浏览 1 评论 0原文

我正在从后端绑定一个枢轴。 我的数据透视表的 xaml 是:

 <controls:Pivot Name="MainPivot" Visibility="Collapsed">
            <controls:Pivot.Background>
                <ImageBrush ImageSource="Images/ItemBrowse.png"></ImageBrush>
            </controls:Pivot.Background>

            <controls:Pivot.HeaderTemplate>
                <DataTemplate>
                    <TextBlock FontSize="38" Text="{Binding title}" Foreground="White"/>
                </DataTemplate>
            </controls:Pivot.HeaderTemplate>

            <controls:Pivot.ItemTemplate>
                <DataTemplate>
                    <ScrollViewer Name="scroll" Margin="-12" Background="LightGray" VerticalScrollBarVisibility="Auto">
                        <StackPanel>

                            <controls:PivotItem  Name="pvtItemPrice" >

                                <StackPanel Orientation="Vertical">
                                    <TextBlock Text="Price" Foreground="Black" FontWeight="Bold" FontSize="28" />
                                    <TextBlock Text="{Binding price}" FontSize="22" Foreground="DarkCyan"/>
                                </StackPanel>

                            </controls:PivotItem>
                            <Border BorderThickness="2" BorderBrush="White" Height="3" Width="470"/>

                            <controls:PivotItem Name="pvtItemDescription" >


                                <StackPanel Orientation="Vertical">
                                    <TextBlock Text="Description" Foreground="Black" FontWeight="Bold" FontSize="28" />
                                    <TextBlock Text="{Binding description}" Foreground="Gray" FontSize="22" Width="460" TextWrapping="Wrap"/>
                                </StackPanel>
                            </controls:PivotItem>
                            <Border BorderThickness="2" BorderBrush="White" Height="3" Width="470"/>




                            <controls:PivotItem Name="pvtItemLocation"  >
                                <StackPanel Orientation="Vertical">
                                    <TextBlock Text="Location:" Foreground="Black" Padding="5" FontWeight="Bold" FontSize="28" />
                                    <Grid >
                                        <StackPanel>
                                            <TextBlock Text="{Binding location}" FontSize="22" Foreground="Brown" Width="460" TextWrapping="Wrap" />
                                            <Button BorderBrush="Transparent"  Foreground="Yellow"  Name="btnShowMap" Width="370" Content="View in Map"  Click="btnShowMap_Click" Height="100">
                                                <Button.Background>
                                                    <ImageBrush ImageSource="Images/ImgBtns.png" />
                                                </Button.Background>
                                            </Button>
                                        </StackPanel>
                                    </Grid>
                                </StackPanel>
                            </controls:PivotItem>

                        </StackPanel>
                    </ScrollViewer>
                </DataTemplate>
            </controls:Pivot.ItemTemplate>

        </controls:Pivot>

但我必须根据用户值显示或隐藏 btnShowMap 。但我无法从后端获得控制权。无论如何我能找到解决方案吗?

I am binding a Pivot from backend.
The xaml for my Pivot is:

 <controls:Pivot Name="MainPivot" Visibility="Collapsed">
            <controls:Pivot.Background>
                <ImageBrush ImageSource="Images/ItemBrowse.png"></ImageBrush>
            </controls:Pivot.Background>

            <controls:Pivot.HeaderTemplate>
                <DataTemplate>
                    <TextBlock FontSize="38" Text="{Binding title}" Foreground="White"/>
                </DataTemplate>
            </controls:Pivot.HeaderTemplate>

            <controls:Pivot.ItemTemplate>
                <DataTemplate>
                    <ScrollViewer Name="scroll" Margin="-12" Background="LightGray" VerticalScrollBarVisibility="Auto">
                        <StackPanel>

                            <controls:PivotItem  Name="pvtItemPrice" >

                                <StackPanel Orientation="Vertical">
                                    <TextBlock Text="Price" Foreground="Black" FontWeight="Bold" FontSize="28" />
                                    <TextBlock Text="{Binding price}" FontSize="22" Foreground="DarkCyan"/>
                                </StackPanel>

                            </controls:PivotItem>
                            <Border BorderThickness="2" BorderBrush="White" Height="3" Width="470"/>

                            <controls:PivotItem Name="pvtItemDescription" >


                                <StackPanel Orientation="Vertical">
                                    <TextBlock Text="Description" Foreground="Black" FontWeight="Bold" FontSize="28" />
                                    <TextBlock Text="{Binding description}" Foreground="Gray" FontSize="22" Width="460" TextWrapping="Wrap"/>
                                </StackPanel>
                            </controls:PivotItem>
                            <Border BorderThickness="2" BorderBrush="White" Height="3" Width="470"/>




                            <controls:PivotItem Name="pvtItemLocation"  >
                                <StackPanel Orientation="Vertical">
                                    <TextBlock Text="Location:" Foreground="Black" Padding="5" FontWeight="Bold" FontSize="28" />
                                    <Grid >
                                        <StackPanel>
                                            <TextBlock Text="{Binding location}" FontSize="22" Foreground="Brown" Width="460" TextWrapping="Wrap" />
                                            <Button BorderBrush="Transparent"  Foreground="Yellow"  Name="btnShowMap" Width="370" Content="View in Map"  Click="btnShowMap_Click" Height="100">
                                                <Button.Background>
                                                    <ImageBrush ImageSource="Images/ImgBtns.png" />
                                                </Button.Background>
                                            </Button>
                                        </StackPanel>
                                    </Grid>
                                </StackPanel>
                            </controls:PivotItem>

                        </StackPanel>
                    </ScrollViewer>
                </DataTemplate>
            </controls:Pivot.ItemTemplate>

        </controls:Pivot>

But I have to show or hide the btnShowMap according to the user value. But I cannot get the control from backend. Is there anyway I can get the solution for this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

↘人皮目录ツ 2025-01-04 12:49:18

如果页面中有上述标记,您应该会发现 Visual Studio 将为您生成一个 btnShowMap 字段。只需导航到该文件的代码隐藏即可找到它。

If you have the markup above within a page, you should find that Visual Studio will have generated a btnShowMap field for you. Simply navigate to the code-behind for this file and you will find it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文