简体   繁体   English

Windows 8.1 app如何在BottomAppBar弹出窗口中访问控件?

[英]Windows 8.1 app How to access control within BottomAppBar flyout?

x:Name does not work on user controls that are within a flyout that is a child element of a page's BottomAppBar. x:名称不适用于作为页面BottomAppBar的子元素的弹出窗口内的用户控件。 I'm trying to access this custom userControl from the code behind. 我正在尝试从后面的代码访问此自定义userControl。 Any ideas how this can be done? 有什么想法可以做到这一点?

<Page.BottomAppBar>
    <AppBar IsOpen="{Binding AppBarOpen,
                             Mode=TwoWay}"
            IsSticky="{Binding AppBarSticky,
                               Mode=TwoWay}">
        <Grid>
<!--Other controls and whatnot here including column specifications and leftpanel stuff-->
<VariableSizedWrapGrid x:Name="appbarrightPanel"
                                   Grid.Column="1"
                                   HorizontalAlignment="Right"
                                   Orientation="Horizontal">
<AppBarButton x:Name="appbarbtnUpload"
                              Click="appbarbtnUpload_Click"                                 
                              Label="Upload">
                    <AppBarButton.Icon>
                        <BitmapIcon Width="22"
                                    Height="22"
                                    UriSource="ms-appx:///Assets/TopAppbarIcons/icon_upload.png" />
                    </AppBarButton.Icon>
<FlyoutBase.AttachedFlyout>
                        <Flyout>
                            <usercontrols:UploadControl x:Name="uploadControl"  ParentPage="Tag List Page" FileChoosen="UploadControl_FileChoosen" Margin="-20"/>
                        </Flyout>
                    </FlyoutBase.AttachedFlyout>
                </AppBarButton>
            </VariableSizedWrapGrid>
        </Grid>
    </AppBar>
</Page.BottomAppBar>

Again, doing uploadControl.blah does not work because I cannot even access uploadControl. 再次,uploadControl.blah不起作用,因为我甚至无法访问uploadControl。

I wasn't able to directly connect to it via it's name BUT I was able to hook into it's Loaded and Unloaded events to access it. 我无法通过它的名称直接连接到它但是我能够挂钩它的Loaded和Unloaded事件来访问它。 You can probably get the object itself by casting the sender object. 您可以通过转换发送方对象来获取对象本身。 Just being able to access the object in the onLoad was good enough for my purposes. 只是能够访问onLoad中的对象对我的目的来说已经足够了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Windows Store App 8.1 C#中将具有DataTemplate的ListView添加到Button Flyout - How to add ListView with datatemplate to Button Flyout in windows store app 8.1 c# 如何在集线器部分数据模板Windows Phone 8.1中访问控件 - How do i access a control within a hub section data template windows phone 8.1 列出windows store 8.1 app中菜单弹出窗口中的所有字体和颜色 - List all fonts and colors in menu flyout in windows store 8.1 app Windows Phone 8.1-如何创建弹出窗口(?)并使屏幕的其余部分变暗? - Windows Phone 8.1 - How to create a flyout (?) and dim the rest of the screen? 集线器控制窗口8.1中的访问控制 - Access control inside hub control windows 8.1 如何访问Windows 8.1存储中的Hubsection Datatemplate内的任何控件 - How to access any control inside Hubsection Datatemplate in Windows 8.1 store 使用BottomAppBar显示弹出窗口 - Show flyout using BottomAppBar Windows Phone 8.1中的项目控件弹出问题 - Problems with flyout over itemscontrol in Windows Phone 8.1 弹出菜单Windows Phone 8.1暂停列表视图 - Flyout Menu windows phone 8.1 on hold Listview C#WinRT Windows Phone 8.1-导航栏可见时,应用栏覆盖弹出菜单 - C# WinRT Windows Phone 8.1 - App Bar Covers Flyout Menu When Nav Bar Is Visible
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM