Wpf组合框错误如何 [英] Wpf comboboxes errors how to

查看:79
本文介绍了Wpf组合框错误如何的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有4个WPF comboBox我想将数据添加到XAML我有一个代码但是会出错。

内容被设置为多个实例。我想为每个组合框设置不同。

迷失在网格开始的地方。这对我来说是一个新手,并试图做一些应该简单的事情。我不知道如何包装每个或完成每个组合框

完整代码如下



谢谢







I have 4 WPF comboBox I want to add data to the XAML i have a code but get errors.
Content is set to more then one instance. I want to set different for each combobox.
getting lost on where the grid starts. This is very new to me and trying to do what should be simple. I dont know how to wrap each or complete each combobox
full code below

Thanks



<pre><Window x:Class="WPF_Shift_End_Report.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

        xmlns:local="clr-namespace:WPF_Shift_End_Report"

        mc:Ignorable="d"

        Title="Shift End Report" Height="550" Width="948" WindowStyle="None">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="44*"/>
            <ColumnDefinition Width="4*"/>
            <ColumnDefinition Width="187*"/>
        </Grid.ColumnDefinitions>
        <Grid HorizontalAlignment="Left" Height="542" VerticalAlignment="Top" Width="203" Background="#FFBBC9C6" Grid.ColumnSpan="3">
            <Button x:Name="btn_Home" Content="Home" HorizontalAlignment="Left" VerticalAlignment="Top" Width="59" Margin="50,180,0,0" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="White" FontSize="16" FontWeight="Bold" RenderTransformOrigin="0.458,-0.48"/>
            <Image x:Name="Home" HorizontalAlignment="Left" Height="28" VerticalAlignment="Top" Width="32" Margin="10,177,0,0" Source="ICO/Dog House_40px.png"/>
        </Grid>
        <Grid HorizontalAlignment="Left" Height="28" Margin="65,0,0,0" VerticalAlignment="Top" Width="875" RenderTransformOrigin="-0.133,-0.811" Background="#FFBBC9C6" MouseLeftButtonDown="Grid_MouseLeftButtonDown" Grid.ColumnSpan="3"/>
        <Image x:Name="Exit" HorizontalAlignment="Left" Height="28" VerticalAlignment="Bottom" Width="25" Grid.Column="2" Margin="713,0,0,514" Source="ICO/Delete_29px.png" MouseLeftButtonDown="image_MouseLeftButtonDown" RenderTransformOrigin="1.64,0.5" OpacityMask="Black"/>
        <Image x:Name="image" HorizontalAlignment="Left" Height="100" VerticalAlignment="Top" Width="119" Source="ICO/nissan-logo.ico" Margin="8,10,0,0"/>
        <Button x:Name="btn_SSAR" Content="SSAR" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="91,352,0,0" Background="{x:Null}" Foreground="White" FontSize="16" FontWeight="Bold" BorderBrush="{x:Null}"/>
        <Button x:Name="btn_Part_Shortage" Content="Part Shortage" HorizontalAlignment="Left" VerticalAlignment="Top" Width="132" Margin="44,225,0,0" Background="{x:Null}" Foreground="White" FontSize="16" FontWeight="Bold" BorderBrush="{x:Null}"/>
        <Button x:Name="btn_Attendance" Content="Attendance" HorizontalAlignment="Left" VerticalAlignment="Top" Width="108" Margin="58,272,0,0" Background="{x:Null}" Foreground="White" FontSize="16" FontWeight="Bold" BorderBrush="{x:Null}"/>
        <Button x:Name="btn_Hot_Calls" Content="Hot Calls" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="91,307,0,0" Background="{x:Null}" Foreground="White" FontSize="16" FontWeight="Bold" BorderBrush="{x:Null}"/>
        <Button x:Name="btn_Restriction" Content="Restriction" HorizontalAlignment="Left" VerticalAlignment="Top" Width="85" Margin="81,426,0,0" Background="{x:Null}" Foreground="White" FontSize="16" FontWeight="Bold" BorderBrush="{x:Null}"/>
        <Button x:Name="btn_open_Parts" Content="Open Parts Issue" HorizontalAlignment="Left" VerticalAlignment="Top" Width="138" Margin="44,382,0,0" Background="{x:Null}" Foreground="White" FontSize="16" FontWeight="Bold" BorderBrush="{x:Null}" Grid.ColumnSpan="2"/>
        <Image x:Name="PartShortage" HorizontalAlignment="Left" Height="25" VerticalAlignment="Top" Width="36" Margin="10,225,0,0" RenderTransformOrigin="-5.056,0.638" Source="ICO/Administrative Tools_40px.png"/>
        <Image x:Name="Restriction" HorizontalAlignment="Left" Height="25" VerticalAlignment="Top" Width="36" Margin="10,445,0,0" Source="ICO/Medical 2.jpg" RenderTransformOrigin="0.556,-0.76"/>
        <Image x:Name="Attendance" HorizontalAlignment="Left" Height="25" VerticalAlignment="Top" Width="36" Margin="10,272,0,0" RenderTransformOrigin="0.583,2.84" Source="ICO/Add User Group Man Man_40px.png"/>
        <Image x:Name="image4" HorizontalAlignment="Left" Height="25" VerticalAlignment="Top" Width="36" Margin="8,352,0,0" RenderTransformOrigin="-6.667,0.04"/>
        <Image x:Name="image5" HorizontalAlignment="Left" Height="25" VerticalAlignment="Top" Width="36" Margin="10,401,0,0" RenderTransformOrigin="0.5,1.48"/>
        <Image x:Name="HotCalls" HorizontalAlignment="Left" Height="25" VerticalAlignment="Top" Width="36" Margin="10,307,0,0" RenderTransformOrigin="-1.63,0.65" Source="ICO/White flame.png" OpacityMask="#FF891B15"/>
        <Grid HorizontalAlignment="Left" Height="77" VerticalAlignment="Top" Width="737" Grid.Column="2" Margin="11,28,0,0" Background="#FF23A2B6">
            <ComboBox x:Name="comboBox2" HorizontalAlignment="Left" VerticalAlignment="Top" Width="73" Margin="150,45,0,0"/>
            <ComboBoxItem Content="X"/>
            <ComboBoxItem Content="Y"/>
            <ComboBoxItem Content="Z"/>
                        
            <ComboBox x:Name="comboBox3" HorizontalAlignment="Left" Margin="257,45,0,0" VerticalAlignment="Top" Width="78" RenderTransformOrigin="-0.013,0.409"/>
            <ComboBoxItem Content="a"/>
            <ComboBoxItem Content="s"/>
            <ComboBoxItem Content="d"/>
                
            <ComboBox x:Name="comboBox4" HorizontalAlignment="Left" VerticalAlignment="Top" Width="79" Margin="363,45,0,0"/>
            <ComboBoxItem Content="f"/>
            <ComboBoxItem Content="g"/>
            <ComboBoxItem Content="h"/>
                    
            <ComboBox x:Name="comboBox5" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" Margin="486,45,0,0"/>
            <ComboBoxItem Content="j"/>
            <ComboBoxItem Content="k"/>
            <ComboBoxItem Content="l"/>
                        <ComboBox>
            <ComboBox x:Name="comboBox6" HorizontalAlignment="Left" VerticalAlignment="Top" Width="86" Margin="632,45,0,0" RenderTransformOrigin="0.802,0.545"/>
           
        </Grid>
        <DatePicker HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="2" Margin="31,68,0,0"/>

    </Grid>
</Window>





What I have tried:



can not find an example of comboboxs together in a group.



What I have tried:

can not find an example of comboboxs together in a group.

推荐答案

When you get that error it means you have the Content set both as an attribute and in the body of the XAML.



The XAML you have is incomplete so I can’t say 100% where it is. As an example, this will cause an error:

When you get that error it means you have the Content set both as an attribute and in the body of the XAML.

The XAML you have is incomplete so I can't say 100% where it is. As an example, this will cause an error:
<ComboBoxItem Content="d">e</ComboBoxItem>



In this case you’re trying to set Content in two places \"d\" and \"e\" so you get the error.


In this case you're trying to set Content in two places "d" and "e" so you get the error.


这篇关于Wpf组合框错误如何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆