小编Mar*_*all的帖子

WPF DockPanel IsMouseOver仅在子控件被鼠标悬停时触发

我的应用程序有一种瓷砖系统.请参阅以下代码:

<WrapPanel Grid.Column="0" Grid.Row="1">
    <DockPanel Style="{StaticResource Panel}">
        <Label Content="Upload"/>
        <Image Width="40">
            <Image.Source>
                <BitmapImage DecodePixelWidth="40" UriSource="images/download.png" />
            </Image.Source>
        </Image>
    </DockPanel>
</WrapPanel>
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,我有了主容器([icode] WrapPanel [/ icode]),然后我有了多个[icode] DockPanel [/ icode],它们构成了tile本身.

出于某些原因,当我将鼠标悬停在DockPanel上时,IsMouseOver触发器不会触发,但是当我将鼠标悬停在它的任何一个子节点上时它会触发.触发后,它会一直触发,直到我的鼠标离开DockPanel.

这是风格:

<Style x:Key="Panel" TargetType="DockPanel">
    <Setter Property="Margin" Value="4" />
    <Setter Property="Cursor" Value="Hand" />
    <Setter Property="Height" Value="118" />
    <Setter Property="Width" Value="118" />
    <Setter Property="LastChildFill" Value="True" />
    <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="True">
            <Setter Property="Background" Value="#FF212121" />
        </Trigger>
    </Style.Triggers>
    <Style.Resources>
        <Style TargetType="Label">
            <Setter Property="Foreground" Value="White" />
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="VerticalAlignment" Value="Bottom" />
            <Setter Property="Margin" Value="3" …
Run Code Online (Sandbox Code Playgroud)

wpf xaml

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

JS:来自表单内的GetElementsByName

我试图在我的表单中按名称获取元素,但由于某种原因我得到此错误:

未捕获的TypeError:frm.getElementsByName不是函数

这是我的代码:

function doc(id) { return document.getElementById(id); }

function switchFields() {
    var e = doc("slcSubmit");
    var sel = e.options[e.selectedIndex].value;
    var frm = doc("frmSendmessage");

    var messageFields = [frm.getElementsByName("name"),frm.getElementsByName("email")]; //List of objects

    //Give each object a new class
    for (var i=0;i<messageFields.length;i++) {
        messageFields[i].class = "test";
    }
}
Run Code Online (Sandbox Code Playgroud)

javascript

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

WPF:画布中的中心文本块

我试图将我的 TextBlock 放在 Canvas 的中心,但它似乎没有按预期工作。我希望当添加更多文本时中心点明显改变,使其保持居中。

这就是正在生成的内容,3 个图像显示当有 1 个数字、2 个数字和 3 时。

在此输入图像描述

这是我的控制模板

<Style TargetType="ProgressBar" x:Key="CircularProgress">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ProgressBar">
                    <Grid x:Name="PathGrid" Margin="2" Width="200">
                        <Canvas>
                            <TextBlock x:Name="PathPercentage" Text="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Value, StringFormat={}{0}%}"
                                    Foreground="White"
                                    FontFamily="DefaultFont"
                                    FontSize="{Binding ElementName=PathGrid, Path=ActualWidth, Converter={StaticResource SizeTextOnParent}}">
                                <TextBlock.Margin>
                                    <MultiBinding Converter="{StaticResource CenterElement}">
                                        <Binding ElementName="PathGrid" Path="ActualWidth"/>
                                        <Binding ElementName="PathPercentage" Path="FontSize" />
                                        <Binding ElementName="PathPercentage" Path="FontFamily"/>
                                        <Binding ElementName="PathPercentage" Path="Text"/>
                                    </MultiBinding>
                                </TextBlock.Margin>
                            </TextBlock>
                            <TextBlock Text="{Binding ElementName=PathPercentage, Path=Margin}" />
                            <Ellipse Fill="Transparent" 
                                 Stroke="#434953" 
                                 StrokeThickness="3" 
                                 Width="{Binding ElementName=PathGrid, Path=ActualWidth}" 
                                 Height="{Binding ElementName=PathGrid, Path=ActualWidth}" />

                            <Path x:Name="pathRoot" 
                              Stroke="#8ab71c" 
                              StrokeThickness="6" 
                              HorizontalAlignment="Center" …
Run Code Online (Sandbox Code Playgroud)

c# wpf canvas

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

PHP会话变量可用一页,但不是另一页...

几乎让我的登录脚本工作,虽然会话变量有一个奇怪的问题.我创建了运行登录代码的会话变量

./includes/functions.php

由于某些原因,它们不存在于同一页面上,因为我的check_login函数也在functions.php页面上.但是当我做检查时它失败了:

function login_check($mysqli) {
    //Check if session variables are met
    if (isset($_SESSION['user_id'], $_SESSION['email'], $_SESSION['login_string'])) {
Run Code Online (Sandbox Code Playgroud)

我有另一个名为process_login.php的页面

./php/process_login.php

会话变量在这里工作,因为我从以下代码中获取了正确的信息

<?php
include "../includes/db_connect.php";
include "../includes/functions.php";
include "../includes/required.php";

if(isset($_POST['email'], $_POST['p'])) {
    $email = $_POST['email'];
    $password = hash('sha512', $_POST['p']); //Encrypted password

    if (login($email, $password, $mysqli) == true) {
        //Login success
        echo "Logged in!";
        //header("Location: ".ROOT."index.php");;
    } else {
        //Not user found
        echo "Not user found with those details";
    }
}
?>
<h1>You are logged in as <?=$_SESSION['email']?>!</h1>
<h2>Your user ID is: <?=$_SESSION['user_id']?>.</h2> …
Run Code Online (Sandbox Code Playgroud)

php session

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

PHP正则表达式从URL获取文件名

我不太擅长正则表达式,但是我将如何将文件名与路径中的扩展名分开?

D:/DCIM/image10.jpg

D:/DCIM/image11.jpg

D:/DCIM/image12.jpg

D:/DCIM/image13.jpg

我会从对方那里得到 imagex.jpg 关于字符串,x 是一个数字。

所以基本上搜索“.jpg”然后获取所有其他字符直到“/”。

编辑: 啊,pathinfo 函数将完成这项工作,尽管为了将来的目的,知道如何使用 RegEx 做这样的事情会很好。

php regex

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

WPF:圆形进度条

关于这个主题,我到处都环顾四周,发现了很多信息,看起来都很复杂。我发现这篇文章非常好。

但是它并没有真正分解如何计算进入ArcSegment的值以形成一个完整的圆圈,有没有人有任何建议。只需向我展示如何制作 ArcSegment,它将从一个点开始并围绕 360 度旋转,我将从那里开始工作。

wpf

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

c#转换器获取指定的强制转换无效

我想在我的自定义控件上简单地做一些数学运算.我需要取一个"宽度"值并将其除以转换器参数.

这是绑定:

<Border x:Name="circleBorder"
     Grid.Row="0"
     CornerRadius="{Binding Path=ActualWidth, ElementName=circleGrid}"
     Width="{Binding Path=ActualWidth, ElementName=circleGrid}"
     Height="{Binding Path=ActualWidth, ElementName=circleGrid}"
     BorderBrush="White"
     BorderThickness="{Binding Converter={StaticResource CalculateBorder}, Path=Width, ElementName=circleBorder, ConverterParameter=30}">
Run Code Online (Sandbox Code Playgroud)

这是转换器,它应该做一些简单的数学运算.

public class CalculateBorder : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {   
        return ((double)value / (double)parameter);
    }
    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}
Run Code Online (Sandbox Code Playgroud)

我收到此错误return ((double)value / (double)parameter);:

指定演员表无效.

c# wpf

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

PHP:基于值分离数组

我有以下数组:

$raw = [
    [
        'prop1' => 'somevalue',
        'prop2' => 'anothervalue',
        'path' => 'used'
    ],
    [
        'prop1' => 'somevalue',
        'prop2' => 'anothervalue',
        'path' => 'used'
    ],
    [
        'prop1' => 'somevalue',
        'prop2' => 'anothervalue',
        'path' => 'used'
    ],
    [
        'prop1' => 'somevalue',
        'prop2' => 'anothervalue',
        'path' => 'used'
    ],
    [
        'prop1' => 'somevalue',
        'prop2' => 'anothervalue',
        'path' => 'used'
    ],
    [
        'prop1' => 'somevalue',
        'prop2' => 'anothervalue',
        'path' => 'new'
    ],
    [
        'prop1' => 'somevalue',
        'prop2' => 'anothervalue',
        'path' => 'new' …
Run Code Online (Sandbox Code Playgroud)

php filter

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

Vue 事件处理程序,在所有组件之间共享

我创建了一个新的 Vue 实例并将其分配给我的窗口,这应该让我可以在所有组件中访问它。这应该使我能够访问应用程序中任何位置发出的事件。

但由于某种原因,情况并非如此,有人可以建议我吗?

应用程序.js

window.Vue = require('vue');
window.events = new Vue();
window.app = new Vue({
    el: '#app',
    methods: {
        emit: function (name, params) {
            window.events.$emit(name, params);
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

我在我的应用程序中创建了一个emit方法供我的组件使用,因为简单的调用v-on:change="window.events.$emit('makeChanged', $event)"不起作用,我收到了window未定义的错误。

我正在侦听组件内发出的任何事件,emit如下所示:

window.events.$on('makeChanged', function(evt) {});
Run Code Online (Sandbox Code Playgroud)

编辑:

仍然无法让这个工作......

app.js

Vue.component('models-select', require('./components/results-text/ModelsSelect.vue'));

window.app = new Vue({
    el: '#app',
    methods: {
        emit(name, ...params) {
            this.$root.$emit(name, ...params);
        },
    ...
Run Code Online (Sandbox Code Playgroud)

ModelsSelect.vue

export default {
        props: [ 'endpoint', 'makeId', 'modelId', 'typeId'],
        mounted() {

            this.$root.$on('make-changed', function(evt) {
                console.log(evt); …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js

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

选中检查时隐藏菜单

我正在尝试为移动菜单创建一个切换,但:checked选择器似乎不起作用.

这是代码:

#toggleMenuToggle:checked .nav-css {
  display: none;
}
Run Code Online (Sandbox Code Playgroud)
<label class="desktop-hidden menuToggle" for="toggleMenuToggle">MENU</label>
<input type="checkbox" name="toggleMenuToggle" id="toggleMenuToggle">
<ul id="dropdown-nav" class="nav-css">
  <li class="n1 current">
    <a class="n1">Test</a>
  </li>
</ul>
Run Code Online (Sandbox Code Playgroud)

<ul>选中复选框时,不应该将它的显示设置为无?

html css

0
推荐指数
1
解决办法
73
查看次数

标签 统计

wpf ×4

php ×3

c# ×2

javascript ×2

canvas ×1

css ×1

filter ×1

html ×1

regex ×1

session ×1

vue.js ×1

xaml ×1