小编Vis*_*hal的帖子

PHP Include不显示页眉和页脚

这是我在这个网站上的第一个问题.

我是编程新手.

我在C:/Wamp/WWW/AddressBook/Index.html上有index.html文件,header.html和footer.html文件位于C:/ Wamp/WWW/AddressBook/Includes /

现在我想在index.html中包含这些文件

对于标题

<?php include 'Includes/Header.html'; ?>
Run Code Online (Sandbox Code Playgroud)

并为页脚

<?php include 'Includes/Footer.html'; ?>
Run Code Online (Sandbox Code Playgroud)

但是当我在浏览器中打开index.html时,页眉和页脚都没有显示出来.

php include

4
推荐指数
1
解决办法
2586
查看次数

资源字典中带有标题的多项目组合框?

我已经按照这个问题的公认答案定义了一个带有标题的多列组合框。

它对我不起作用,所以我对其进行了一些更改,现在它可以工作了。这是创建带有标题的多列组合框的 xaml。

   <Page.DataContext>
       <vm:ItemsViewModel />
   </Page.DataContext>

   <Page.Resources>
       <CollectionViewSource x:Key="UnitsCollection" Source="{Binding Units}" />
   </Page.Resources>

   <ComboBox Grid.Row="0" Grid.Column="4" Grid.ColumnSpan="2" Grid.IsSharedSizeScope="True" 
              x:Name="cbUnits" ItemsSource="{DynamicResource Items}" IsEditable="True" TextSearch.TextPath="Symbol"
              SelectedValue="{Binding SelectedUnit}" SelectedValuePath="UnitID">
        <ComboBox.Resources>
            <CompositeCollection x:Key="Items">
                <ComboBoxItem IsEnabled="False">
                    <Grid TextElement.FontWeight="Bold">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition SharedSizeGroup="A" />
                            <ColumnDefinition Width="50" />
                            <ColumnDefinition SharedSizeGroup="B" />
                        </Grid.ColumnDefinitions>
                        <Grid.Children>
                            <TextBlock Grid.Column="0" Text="Name" />
                            <TextBlock Grid.Column="2" Text="Symbol" />
                        </Grid.Children>
                    </Grid>
                </ComboBoxItem>
                <Separator />
                <CollectionContainer Collection="{Binding Source={StaticResource UnitsCollection}}" />
            </CompositeCollection>

            <DataTemplate DataType="{x:Type models:Unit}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition SharedSizeGroup="A" />
                        <ColumnDefinition Width="50" />
                        <ColumnDefinition SharedSizeGroup="B" …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml combobox

4
推荐指数
1
解决办法
7375
查看次数

我应该在这个包装 useSWR 的自定义挂钩中测试什么?

我创建了一个名为 useCity 的自定义挂钩。它正在包装使用 useSWR 进行的 API 调用。

这是钩子的代码:

import useSWR from 'swr';

import { City } from '../interfaces';
import { BASE_URL } from '../../config';

interface CitiesResponse {
  data?: {
    records: {
      fields: {
        city: string;
        accentcity: string;
      }
    }[]
  },
  error?: {
    message: string;
  }
};

interface Props {
  start?: number;
  rows: number;
  query?: string;
  sort?: 'population';
  exclude?: string[];
}

const useCity = ({ start = 0, rows, query, sort, exclude }: Props) => {
  const params = [`start=${start}`, `rows=${rows}`]; …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs jestjs react-testing-library swr

4
推荐指数
1
解决办法
5683
查看次数

在.NET 4.5 WPF中更改ListBox中SelectedItem的背景颜色

我想更改列表框的SelectedItem的背景颜色。我尝试了以下代码:

<ListBox Grid.Column="0" ScrollViewer.HorizontalScrollBarVisibility="Hidden" 
         ItemsSource="{Binding Parents}" DisplayMemberPath="Title"
         Height="35" FontSize="18" BorderThickness="0" Background="#FF2A2A2A" 
         Foreground="White" SelectedIndex="0">

    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel IsItemsHost="True" Orientation="Horizontal"/>
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>

    <ListBox.ItemContainerStyle>
        <Style TargetType="{x:Type ListBoxItem}">
            <Style.Triggers>
                <Trigger Property="IsSelected" Value="True">
                    <Setter Property="BorderThickness" Value="0" />
                    <Setter Property="Background" Value="Transparent" />
                    <Setter Property="Foreground" Value="DodgerBlue" />
                </Trigger>
            </Style.Triggers>

            <Style.Resources>
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" 
                                 Color="Transparent"/>
                <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}"
                                 Color="Transparent" />
            </Style.Resources>
        </Style>
    </ListBox.ItemContainerStyle>
</ListBox>
Run Code Online (Sandbox Code Playgroud)

但是我看不到SelectedItems的背景色有任何变化。有人可以指出以上XAML中的错误吗?

我也想针对此特定样式使用此样式ListBox,因此我不想更改ControlTemplate。

wpf xaml listbox

3
推荐指数
2
解决办法
1856
查看次数

如何在 DataGrid 中验证 Null 或 Empty 单元格

我正在尝试验证 DataGrid 中的单元格。这是我的第一种验证方法。因为我是新手,所以我在验证方面遇到了一些问题。

我创建了一个名为 StringIsNullOrEmptyValidationRule.cs 的类。此类检查字符串是否为空或“”

这是 StringIsNullOrEmptyValidationRule.cs 的代码:

class StringIsNullOrEmptyValidationRule : ValidationRule
{
    private string _errorMessage = "";
    public string ErrorMessage
    {
        get
        {
            return _errorMessage;
        }
        set
        {
            _errorMessage = value;
        }
    }

    public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
    {
        ValidationResult result = new ValidationResult(true, null);

        if (value == null || ((string)value).Trim() == "")
        {
            result = new ValidationResult(false, this.ErrorMessage);
        }

        return result;
    }
}
Run Code Online (Sandbox Code Playgroud)

现在我在 MainWindow.xaml 中有一个数据网格,它绑定到一个名为 People 的 ObservableCollection。这是我的 DataGrid :

<DataGrid x:Name="maindg" ItemsSource="{Binding People}" …
Run Code Online (Sandbox Code Playgroud)

c# validation wpf datagrid

3
推荐指数
1
解决办法
5623
查看次数

将组件键设置为等于 Route 中的路径参数

我有一个定义如下的路线:

<Route exact path="/licenses/:type?" component={Licenses} />
Run Code Online (Sandbox Code Playgroud)

我希望我的组件在类型参数更改时重新渲染,因此,如 react-router 文档中所述,我需要使用一个键。我想要与传递给路由的参数相同的键值。就像是:

<Route exact path="/licenses/:type?" key=":type" component={Licenses} />
Run Code Online (Sandbox Code Playgroud)

但是我无法获取类型参数的值作为键。有没有办法将键设置为与类型参数的值相同?

javascript reactjs react-router

3
推荐指数
1
解决办法
6376
查看次数

类型“T[K]”不满足约束“string |” 数量 | 象征'

我正在创建一个简单的函数来从打字稿中的数组中删除重复项。

我知道有很多不同的方法可以实现该目标,但我的最终目标是了解类型的工作原理,因此我不需要与现有代码不同的解决方案。

我的伪代码:

  • 函数将接受对象数组和对象键作为参数
  • 对象数组将转换为字典,仅包含唯一的条目
  • 从对象构造数组并返回它。

使用 JavaScript 的工作代码示例:

function removeDuplicates(arr, propName) {
  const newArr = [];
  const lookup = {};

  for (let i in arr) {
    lookup[arr[i][propName]] = arr[i];
  }

  for (let i in lookup) {
    newArr.push(lookup[i]);
  }

  return newArr;
}
Run Code Online (Sandbox Code Playgroud)

打字稿代码(抛出类型错误)

我正在尝试将该函数转换为 Typescript,但仍停留在声明查找变量的类型上。

这是我的打字稿代码:

function removeDuplicates<T, K extends keyof T>(arr: T[], propName: K) {
  const newArr: T[] = [];
  const lookup: Partial<Record<T[K], T>> = {};
                               ^^^^ here is the error

  for (let i in arr) {
    lookup[arr[i][propName]] = …
Run Code Online (Sandbox Code Playgroud)

typescript

3
推荐指数
1
解决办法
4412
查看次数

使用锚标记将值传递到另一个php页面

我尝试将listID的值从list.php传递给Delete.php.使用锚标记

这是我的代码:

<A HREF = "Delete.php?PID = <?php echo $row['PersonID']; ?>"> Delete </A>
Run Code Online (Sandbox Code Playgroud)

该值是正确传递但不知何故我没有被重定向到Delete.php任何人都可以注意到上述行中的问题?

php anchor

2
推荐指数
1
解决办法
2万
查看次数

在asp.net中使面板可见或不可见

我的页面上有一个按钮.我的页面上有一个面板.我的页面上还有一个多行文本框.

现在我想让面板可见和不可见,而不会打扰下面文本框的位置.就像facebook上的通知面板一样.

以下是使面板可见/不可见的代码:

Protected Sub btnReauests_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnReauests.Click

    If pnlShowRequests.Visible = True Then
        pnlShowRequests.Visible = False
    Else
        pnlShowRequests.Visible = True
    End If
End Sub
Run Code Online (Sandbox Code Playgroud)

我也试过像这样设置面板的z顺序样式

<asp:Panel ID="pnlShowRequests" runat="server" style =" z-index : 1; position : relative; top: 0px; left: 255px; width: 206px; height: 200px;" Visible="False">
            </asp:Panel>
Run Code Online (Sandbox Code Playgroud)

vb.net asp.net panel visible

2
推荐指数
1
解决办法
7336
查看次数

将类声明为静态和在app.xaml文件中创建实例有什么区别?

假设我有两页在WPF即Page1.xamlPage2.xaml.我有一个名为的viewmodel PageViewModel.cs.这两个页面共享相同的viewmodel.

我可以通过两种方法编写代码:

Mehod1:

PageViewModel.cs

public static class PageViewModel
{

}
Run Code Online (Sandbox Code Playgroud)

的Page1.xaml

<Window.........>
    <Window.DataContext>
        <vm:PageViewModel />
    </Window.DataContext>
</Window>
Run Code Online (Sandbox Code Playgroud)

Page2.xaml

<Window.........>
    <Window.DataContext>
        <vm:PageViewModel />
    </Window.DataContext>
</Window>
Run Code Online (Sandbox Code Playgroud)

App.xaml中

Default xaml code.
Run Code Online (Sandbox Code Playgroud)

方法2:

PageViewModel.cs

public class PageViewModel
{

}
Run Code Online (Sandbox Code Playgroud)

的Page1.xaml

<Window DataContext={StaticResource PageViewModel}>
    ..........
    ..........
</Window>
Run Code Online (Sandbox Code Playgroud)

Page2.xaml

<Window DataContext={StaticResource PageViewModel}>
    ..........
    ..........
</Window>
Run Code Online (Sandbox Code Playgroud)

App.xaml中

<vm:PageViewModel x:Key="PageViewModel" />
Run Code Online (Sandbox Code Playgroud)

任何人都可以解释上述两种方法之间的区别吗?

c# wpf xaml

2
推荐指数
2
解决办法
121
查看次数