C++开发uwp的坑

来源:互联网 发布:淘宝网店开店流程 编辑:程序博客网 时间:2024/06/05 16:53
 <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid x:Name="MyGrid">            
        </Grid>
    </Grid>

Button^ bt;
bt = ref new Button();
//控件必须初始化 ref new ;
//也可以 写在同一行
//auto bt= ref new Button();

tx->Margin =Windows::UI::Xaml::Thickness(100.f);


auto h = ref new Windows::Web::Http::HttpClient();
auto btn = ref new Button();
btn->Content = "an niu ";
btn->FontSize = 48;
btn->Foreground = ref new SolidColorBrush(Colors::Blue);
btn->Background = ref new SolidColorBrush(Colors::LightGreen);
btn->HorizontalAlignment = Windows::UI::Xaml::HorizontalAlignment::Center;
//click速度慢于tapped
btn->Tapped += ref new Windows::UI::Xaml::Input::TappedEventHandler(this, &App2::MainPage::OnTapped);
auto tx = ref new TextBlock();
//tx->HorizontalAlignment = Windows::UI::Xaml::HorizontalAlignment::Right;
tx->TextWrapping = Windows::UI::Xaml::TextWrapping::WrapWholeWords;
tx->TextAlignment = TextAlignment::Left;
//tx->OpticalMarginAlignment = OpticalMarginAlignment::None;
tx->Text = "TEXT";
tx->FontSize = Add(10, 38);
tx->Margin =Windows::UI::Xaml::Thickness(100.f);
tx->Foreground = ref new SolidColorBrush(Colors::PaleVioletRed);
MyGrid->Children->Append(tx);
MyGrid->Children->Append(btn);

void App2::MainPage::OnTapped(Platform::Object ^sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs ^e)
{
((Button^)sender)->Background = ref new SolidColorBrush(Colors::LightCyan);
((Button^)sender)->Foreground = ref new SolidColorBrush(Colors::Red);
auto fileopenpicker = ref new FileOpenPicker();
fileopenpicker->SuggestedStartLocation = PickerLocationId::DocumentsLibrary;
fileopenpicker->FileTypeFilter->Append(".pdf");
//fileopenpicker->CommitButtonText = "打开";//默认值是  打开
fileopenpicker->CommitButtonText = "是否tap你需要的文档,并确定";
fileopenpicker->ViewMode = PickerViewMode::List;
fileopenpicker->PickMultipleFilesAsync();
}
原创粉丝点击