小编Zom*_*eep的帖子

WPF DataBinding - 来自重复控制按钮的Fire事件

从下面我对一般结合的问题,我想寻求帮助,在下面的情形.

我有一个通过ListBox控件中的DataTemplate显示的对象集合(imageFileData).控件绑定到ObservableCollection.集合和模板都在我的应用程序xaml和xaml.cs文件中定义.向集合中动态添加项目按预期工作,并在列表框中显示新的模板化项目.好.

我希望能够做的一件事是通过单击DataTemplate中定义的按钮从集合中删除特定项.为按钮定义Click处理程序允许我处理事件,但我不知道从哪里获取与模板化按钮相关的imageFileData对象.我的按钮的事件处理程序显然将按钮作为发件人和一组RoutedEventArgs传递,但我无法弄清楚如何将此数据与集合中的项目关联以允许我将其删除.

任何人都可以帮助我,或者我注定要尴尬和毫无结果的谷歌搜索,因为我不知道从哪里开始?;)

谢谢ZS

data-binding wpf event-handling

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

一种通过命令行传递字符串@ start到c#的方法

我一直在制作一个让我自己的IP摄像头弹出的项目.
我有这个工作,但现在想从命令行启动它,但通过特定的相机IP进入.
我的编程技巧有限,对C#来说很新
.带字符串的代码是

this.textBox_IP.Text = "xxx.xxx.xxx.xxx"
Run Code Online (Sandbox Code Playgroud)

我已经坚持了几天如何传递ip,所以在cmdline

IpCam.exe xxx.xxx.xxx.xxx
Run Code Online (Sandbox Code Playgroud)

任何人都有解决方案如何解决这个问题

c# ip visual-studio-2010

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

尝试Catch Finally - 处理读者

在C#中,我TRY..CATCH..FINALLY在代码中使用了一个围绕执行存储过程的块.

如果有例外,那么FINALLY我想要关闭读者 - PolicyResult以及连接.

但是,我收到一个错误

PolicyResult名称在当前上下文中不存在

PolicyResult是在中定义的DataReader,TRY但似乎在该FINALLY部分中未被识别.

为什么?

        public static IEnumerable GetPolicies(int? MasterPkgID)
        {
            // Create a list of policies belonging to the master package.
            List<AdditionalInterestPolicyData> additionalInterestPolicyData = new List<AdditionalInterestPolicyData>();

            // Set the SQL connection to the database.
            SqlConnection objConn = new SqlConnection(ConfigurationManager.ConnectionStrings["QUESTIONNAIRE2"].ConnectionString);

            try
            {
               // Open the connection.
               objConn.Open();

               // Get the list of policies by executing a stored procedure.
               SqlCommand PolicyCmd = new SqlCommand("p_expapp_get_policy_detail_by_master_pkg", objConn);
               PolicyCmd.Parameters.Clear();
               PolicyCmd.CommandType = …
Run Code Online (Sandbox Code Playgroud)

c#

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

布局自动缩放Windows 8

我想做一个简单的布局:这是我的代码:

<ScrollViewer Grid.Column="1" Grid.Row="1" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Disabled" VerticalContentAlignment="Stretch">
    <StackPanel  Name="MainStack" Orientation="Horizontal">     
        <StackPanel Width="800" Height="800" Margin="140,0,10,0" Background="#FFAC3737"/>
            <StackPanel Width="400" Height="800" Margin="0,0,10,0">
                <StackPanel Width="400" Height="395" Background="Black" HorizontalAlignment="Left" Margin="0,0,0,10" />
                <StackPanel Width="400" Height="395" Background="Black" HorizontalAlignment="Left" />              
            </StackPanel>

            <StackPanel Width="400" Height="800" Margin="0,0,10,0">
                <StackPanel Width="400" Height="395" Background="Black" HorizontalAlignment="Left" Margin="0,0,0,10" />
                <StackPanel Width="400" Height="395" Background="Black" HorizontalAlignment="Left" />              
            </StackPanel>

            <StackPanel  Width="400" Height="800" Margin="0,0,10,0">
                <StackPanel Width="400" Height="395" Background="#FF5686AE" HorizontalAlignment="Left" Margin="0,0,0,10" />
                <StackPanel Width="400" Height="395" Background="#FF5583AA" HorizontalAlignment="Left" />              
            </StackPanel>

            <StackPanel Width="400" Height="800" Margin="0,0,10,0">
                <StackPanel Width="400" Height="395" Background="#FF5180A8" HorizontalAlignment="Left" Margin="0,0,0,10" /> …
Run Code Online (Sandbox Code Playgroud)

xaml windows-8

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